View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Greg Koppel Greg Koppel is offline
external usenet poster
 
Posts: 79
Default Sending formatted email from Excel

Here is some code that allows html formatting, with the htmlbody line.

Option Explicit

Dim ol, MailSendItem, olns, olMailItem
Dim today As Date
Dim mySubj, myAddr, myBody, myAttachments
Dim myFile

Sub NewMail()
Set ol = CreateObject("Outlook.Application")
Set MailSendItem = ol.CreateItem(olMailItem)
Set olns = ol.GetNamespace("Mapi")

mySubj = Range("B2")
myAddr = Range("D2")
myBody = Range("A1")
With MailSendItem
.Subject = mySubj
'.Body = myBody
.htmlbody = "<HTML<H2My HTML page.</H2<BODY<IMG
SRC=""WBHats.jpg""</BODY</HTML"
.To = "
.attachments.Add "C:\temp\wb_logo\WBHats.jpg"
'.CC = "
'.Attachments.Add "C:\temp\011302.zip"
.Send
End With
End Sub

HTH, Greg

"Trum" wrote in message
...
I have a macro that generates a personalized email for each row that data

(fname and email) exists. In a specified cell, I have the email message,
but can not get any formatting to get carried into the generated email. All
text goes in the email as normal (no bold, italics, etc). Is there any way
I can get that text to format correctly in the generated email? Even if it
takes placing some text in the actual message and then substituting
something when the macro runs (which I do now to insert line breaks), that
would be fine. If only there existed a hex value for bold beginning anf
bold ending...

Any ideas?