2012-04-24 18 views
0

中聲明olFormatHtml我試圖發送格式爲HTML的郵件,但出現錯誤,表明olFormatHtml未被聲明。我如何申報?如何在vb

+1

出錯了。用'Outlook.OlBodyFormat.olFormatHTML'替換'olFormatHtml'。很高興回答我自己 – ken 2012-04-24 09:37:59

回答

0

Outlook.OlBodyFormat.olFormatHTML

1

我使用VBA在Excel 2007工作簿附加到電子郵件和格式化電子郵件的正文替換olFormatHtml。我只是嘗試了這個建議並得到了一個運行時錯誤438:對象不支持這個屬性或方法。

相反,我設置.bodyformat = 2顯示電子郵件文本爲HTML,它的工作。例如....

Set Outlook = CreateObject("Outlook.Application") 
Set MailItem1 = Outlook.CreateItem(0) 

With MailItem1 
    .BodyFormat = 2 
    'sample formatting change.... 
    .htmlbody = "<font color = 'red'>" & "SAMPLE TEXT" & "</font><br/>" 
    .display 
End With 

Set MailItem1 = Nothing 
Set Outlook = Nothing