Automate Outlook email creation

I got this from a past question, and I want to alter it a bit.
In another question, an expert had created an HTML template to use that was perfect for my needs.
How can I 'load' that HTML template as my objMail.Body below?

    Dim objNameSpace As Outlook.NameSpace
    Dim objMail As Outlook.MailItem
    Set objOutlookApp = Outlook.Application
    Set objNameSpace = objOutlookApp.GetNamespace("MAPI")
   
    Set objMail = objOutlookApp.CreateItem(olMailItem)
    objMail.To = "user@domain.com"
    objMail.Subject = "subject"
    objMail.Body = "message"
    objMail.Save
LVL 67
sirbountyAsked:
Who is Participating?
 
softplusCommented:
Hi sirbounty,
Add it as an attachment. The "normal" body will be shown in clients that don't support html-mails, all others will display the html file as message :)
0
 
softplusCommented:
objMail.Attachments.Add('Message.html', olByValue, 1, 'Message.Html')

0
 
sirbountyAuthor Commented:
I'll have to dig up the old question - before I was given an html template with a variable at the end to 'add' the file list to the end of the email.
I'd still like to be able to do that...
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
softplusCommented:
You can still add other attachments, that's no problem, just continue calling objMail.Attachments.Add with other files. If you use an html-template, just read it from the file, fill the template in and save it as a temporary file, then attach the file, send the mail + delete the temp. file.
0
 
cjardCommented:
use CDO

see the advice i gave in my first comment in the following thread:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21418776.html

or search the page for "CDO"
0
 
cjardCommented:
you ahve the advantage that it doewsnt say "warning, some program is trying to send mail pretending to be you, do you want to send it?"
0
 
sirbountyAuthor Commented:
Thanx to you both - I need a few more days to look over this in combination with my other code to see if I can merge the two...
I appreciate your time. :)
0
 
sirbountyAuthor Commented:
Haven't really had much time for this yet, but my scanning will pickup again after the first.
I don't want to leave the thread open that long though, so we'll assume your posts will do it and I'll ask followups later, if needed.

Thanx!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.