Hi
I want to be able to send a basic e-mail with the body text containing certain words in bold and underlined.
I have tried to force Outlook 2003 to convert the message to Rich Text or HTML format with no success.
Please can anyone assist or even tell me if it is possible?
I have the following code:
Code:Sub Mail_small_Text_Outlook() 'Working in Office 2000-2007 Dim OutApp As Object Dim OutMail As Object Dim strbody As String Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) strbody = "Hi Roxanne" & vbNewLine & vbNewLine & _ "Sorry for all the e-mails but " & _ "I am testing something for Martin." & vbNewLine & vbNewLine & _ "Thank you" & vbNewLine & vbNewLine & _ "Tom" On Error Resume Next With OutMail .To = "test@test.com" .CC = "" .BCC = "" .Subject = "Test for Tom" .Body = strbody 'You can add a file like this '.Attachments.Add ("c:\MailBody.txt") .Send 'or use .Display End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing End Sub
Last edited by mabbutt; 09-28-2009 at 07:15 AM.
Use HTMLBody and then use standard HTML mark-up, eg:
Code:Sub Mail_small_Text_Outlook() 'Working in Office 2000-2007 Dim OutApp As Object Dim OutMail As Object Dim strbody As String Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) strbody = "Hi <b>Roxanne</b>" & vbNewLine & vbNewLine & _ "Sorry for all the e-mails but " & _ "I am testing <u>something</u> for <i><font color=red>Martin</font></i>." & vbNewLine & vbNewLine & _ "Thank you" & vbNewLine & vbNewLine & _ "Tom" On Error Resume Next With OutMail .To = "test@test.com" .CC = "" .BCC = "" .Subject = "Test for Tom" .HTMLBody = strbody 'You can add a file like this '.Attachments.Add ("c:\MailBody.txt") .Send 'or use .Display End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing End Sub
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Hi DonkeyOte
Thank you so much that is great!!
Would it be possible to use a CSS style sheet instead of the formatting?
I can do this in normal HTML I just need to know the syntax for Excel.
Re: CSS - no idea... I wouldn't have thought so, no.
Re: VBA - simply code the HTML mark up into the string as illustrated.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
DonkeyOte
Thank you!!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks