2014-01-21 28 views
1

我有以下部分的代碼,這是自動回覆系統im開發的一部分。據我瞭解,應該使用換行符格式化電子郵件的正文,但是,如附加的屏幕截圖所示,它沒有。有人可以指出oput哪裏會出錯?使用VBA格式化電子郵件正文

With NewForward 
      .Subject = "'TEST' Hazard report reciept number: HAZ" & IDnumber 
      .To = strSender 
      .BCC = "xxxxxxxxxxxx" 
      .HTMLBody = "Please accept this email as confirmation that xxxx has received your road defect notification. xxxxx will investigate and action your notification according to priority and to ensure public safety. For further information, please phone xxxxx on 4221 6111 and quote reference number " & vbCrLf & IDnumber & vbCrLf & "Your original report can be seen below:" & vbCrLf & report_body 
      .Send 
     End With 

圖片: Email Screenshot

回答

4

如果您使用.HTMLBody那麼您應該使用HTML Tags來編寫它。
試試這個:

Dim EBody as String 

EBody = "Please accept this email as confirmation that xxxx has received your road defect notification." & "<br>" _ 
    & "xxxxx will investigate and action your notification according to priority and to ensure public safety." & "<br>" _ 
    & "For further information, please phone xxxxx on 4221 6111 and quote reference number:" & "<br>" _ 
    & IDnumber & "Your original report can be seen below:" & "<br>" _ 
    & reportbody 

With NewForward 
    .Subject = "'TEST' Hazard report reciept number: HAZ" & IDnumber 
    .To = strSender 
    .BCC = "xxxxxxxxxxxx" 
    .HTMLBody = Ebody 
    .Send 
End With 

希望這對你的作品。
此外,您的reportbody應使用HTML Tags以相同的格式。

+0

太棒了!偉大的解決方案,完美工作 – scb998

+0

很高興它做到了:D您還可以使用「HTML標籤」更改字體類型,字體顏色和字體大小。如果你想了解更多,你可以開始[這裏](http://www.w3schools.com/html/)。它還允許您查看您生成的代碼的結果。 – L42

1

嘛,值要設置的HTMLBody屬性不包含任何HTML格式...

你常數像vbCrLf沒有格式化的HTML。改用HTML標籤,例如換行符爲<br>

相關問題