Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

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
0
sirbounty
Asked:
sirbounty
  • 3
  • 3
  • 2
3 Solutions
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now