Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-07-2011, 12:11 PM
RMittelman RMittelman is offline Automating Outlook from Access Windows XP Automating Outlook from Access Office 2007
Novice
Automating Outlook from Access
 
Join Date: Dec 2010
Posts: 18
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
  #2  
Old 02-07-2011, 03:11 PM
RMittelman RMittelman is offline Automating Outlook from Access Windows XP Automating Outlook from Access Office 2007
Novice
Automating Outlook from Access
 
Join Date: Dec 2010
Posts: 18
RMittelman is on a distinguished road
Default

Follow-up:

I notice there is a .HTMLBody property to the outlook message object. When I use this, the message now contains the text only, with <div>, etc tags not visible.

Problem with this is that the message no longer looks correct. My default font is replaced with Times New Roman, and my signature style, including font, size and colors is negated, also appearing in Times New Roman.

A possible solution is to strip all the HTML codes from the text before supplying it to the message's .Body property. Any ideas?

Thanks...
Reply With Quote
Reply

Tags
access, outlook 2007, vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automating document updates with new text wordfoolish2 Word 0 01-04-2011 01:01 PM
Automating an address from an Abbreviation Panzer Word 0 04-12-2010 06:11 AM
Access 2007 Upgrade After Initial Install - Access 2003 Won't Remove wcb Office 1 01-25-2010 04:08 AM
Automating Outlook from Access Outlook Access From The Web jshollis Outlook 1 05-06-2009 03:22 PM
Automating Cel Population of .jpg skoz55 Excel 0 01-21-2009 03:43 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:52 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft