View Single Post
 
Old 02-07-2011, 12:11 PM
RMittelman RMittelman is offline Windows XP Office 2007
Novice
 
Join Date: Dec 2010
Posts: 19
RMittelman is on a distinguished road
Default Automating Outlook from Access

Hi,
I have an Access (2007) database which creates Outlook (also 2007) email messages using VBA, using code such as the following (skipping some code for brevity):
Code:
Dim oOutlook As Outlook.Application
Dim oMsg As Outlook.MailItem
Dim oRecipient As Outlook.Recipient
Dim oAttachment As Outlook.Attachment

Set oOutlook = New Outlook.Application        
Set oMsg = oOutlook.CreateItem(olMailItem)
With oMsg
    .Display
    Set oRecipient = .Recipients.Add(to_item)
    .subject = subject
    .Body = msgBody    
    .Importance = olImportanceNormal
End With
This used to work fine until I changed my access form to use a rich text box to display things like email addresses and URLs properly.
In the above code, msgBody is a String variable storing the value of the RichTextBox control.

Now my email message looks like the following, including the html codes.

<div>Here are the latest list in PDF format. &nbsp;You will need the Adobe Reader to open this file. &nbsp;Download it for free at <a
href="http://get.adobe.com/reader/">http://get.adobe.com/reader/</a></div>
<div>&nbsp;</div>
<div>Verify names are correct, and let me know if any problems. &nbsp;</div>

The outlook message is already set to display as an HTML message. I tried changing this to a RichText message, but to no avail.

Does anybody know how to properly get the rich text into the outlook message body using VBA, so it will show up properly?

Thanks...
Reply With Quote