We help IT Professionals succeed at work.
Get Started

Adding text to an Outlook mail item created from a template in VBA

2,383 Views
Last Modified: 2016-02-10
I use VBA to send emails from an Access 2010 database. I am trying to create a new Outlook item from a .OFT template file which contains a company logo plus Twitter and Facebook logos.  I use the follwoing code:

Public Function SendEMail(emailaddress As String, subjectline As String, bodytext As String)
    Dim MyOutlook As Outlook.Application
    Dim MyMail As Outlook.MailItem
   
    Set MyOutlook = CreateObject("Outlook.Application")
    Set MyMail = MyOutlook.CreateItemFromTemplate("C:\Users\jeffkwells\Data\Access2010\OA\LadyGrover\LadyGSigBlock.oft")

MyMail.To = emailaddress

MyMail.Subject = subjectline

MyMail.Body = bodytext & Chr(13) & Chr(10) & Chr(13) & Chr(10) & MyMail.Body


MyMail.Display

Set MyMail = Nothing

Set MyOutlook = Nothing
End Function

*********

This VBA code removes all of the logo images and leaves plain text. If I remove the "MyMail.Body = " line, the original .OFT file with the images is displayed correctly as an Outlook email. How do I add text (at the beginning of the email) without losing the images?

Thanks.
Comment
Watch Question
Infotrakker Software
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE