ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sending formatted email from Excel (https://www.excelbanter.com/excel-programming/299461-sending-formatted-email-excel.html)

Trum

Sending formatted email from Excel
 
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?

Greg Koppel

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?





All times are GMT +1. The time now is 02:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com