send email using template

  • Thread starter Thread starter judith
  • Start date Start date
J

judith

I am trying to send some information from Access in an email and need some
code to open a new outlook template to paste the information into. I have
saved the template as an .oft file could you help me with the code and saved
the Access information in a temporary word document

Dim olApp As Outlook.Application
Dim msMailItem As MailItem

' Create a new instance of Outlook
Set olApp = New Outlook.Application

' Create a new mail item
Set msMailItem = olApp.CreateItem(olMailItem)

How do I specify a template please. And can I then copy and paste
information from a temporary word document I have created into the body of
the email to retain the format.

Thanks
 
Thanks for the info, I thought I was on the right track but it doesnt seem to
work.
My template file has a logo and some text in it. I have used

Set msMailItem = olApp.CreateItemFromTemplate(templateFile)

where templateFile is the full string path
templateFile = "C:\Documents and
Settings\judith\Desktop\snowlineTemplates\testTemplate.oft"

but the template is not picked up. I have tried deleting the logo but even
with just text in it the template is not used.

Any suggestions please
 
What do you mean by "template is not picked up"? What do oyu do with the
messgae after calling CreateItemFromTemplate?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
I just get my a plain email message but not with the logo and signature I
created on my user template "testTemplate.oft". Am I somehow overwriting the
template stuff with my .body staement? The code I am using is:

Set olApp = New Outlook.Application

' Create a new mail item
templateFile = "C:\Documents and
Settings\judith\Desktop\snowlineTemplates\testTemplate.oft"
Set msMailItem = olApp.CreateItemFromTemplate(templateFile)

With msMailItem

' Assign the subject line
.Subject = strSubject
.Body = strBody

' Address the e-mail
.To = "(e-mail address removed)"

' Save the message
.Save
End With

Thanks
 
Yes, you are overwriting the body with the plain text.
Have you looked at the HTMLBody property?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
Can I add some plain text to the existing body? Or is it possible to copy
some text off a word document onto the clip board and paste that into the
body?
Thanks
 
No, if the mesage is not being displayed (you could then use the Inspector
objects), you need to read the HTMLBody and insert your new text (HTML) at
the appropriate place.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
Thanks for your help Dmitry. I think this is getting a bit beyond me. I will
just attach a .snp file or try to get my customer to upgrade to 2007 and
attach as pdf
Thanks
 
Back
Top