By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,039 Members | 1,824 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,039 IT Pros & Developers. It's quick & easy.

Creating outlook message from template

P: n/a
Hi

I am using the below code to generate an outlook message from a template
from within access. I am getting the 'Object variable or With block variable
not set' error on the line indicated. What am I doing wrong?

Thanks

Regards

Dim OutlookApp As New Outlook.Application
Dim em As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

em = OutlookApp.CreateItemFromTemplate(Template) '<== This line gives the
error.

With em
em.Recipients.Add ("us***@mydomain.com")
em.Recipients.Add ("us***@mydomain.com")
.Subject = "My Subject"
.Body = "Body Text"
.AttachmentAdd "c:\fiewlname.txt"
.Display (False)
End With

Set em = Nothing
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
What is Template? If you have a template named "Template", you need to have
the name in quotes:

em = OutlookApp.CreateItemFromTemplate("Template")

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:41**********************@news.dial.pipex.com. ..
Hi

I am using the below code to generate an outlook message from a template
from within access. I am getting the 'Object variable or With block variable not set' error on the line indicated. What am I doing wrong?

Thanks

Regards

Dim OutlookApp As New Outlook.Application
Dim em As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

em = OutlookApp.CreateItemFromTemplate(Template) '<== This line gives the error.

With em
em.Recipients.Add ("us***@mydomain.com")
em.Recipients.Add ("us***@mydomain.com")
.Subject = "My Subject"
.Body = "Body Text"
.AttachmentAdd "c:\fiewlname.txt"
.Display (False)
End With

Set em = Nothing

Nov 13 '05 #2

P: n/a
Template is a string variable that has the name & path of the outlook oft
file.

Regards

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:Uq****************@news04.bloor.is.net.cable. rogers.com...
What is Template? If you have a template named "Template", you need to have the name in quotes:

em = OutlookApp.CreateItemFromTemplate("Template")

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:41**********************@news.dial.pipex.com. ..
Hi

I am using the below code to generate an outlook message from a template
from within access. I am getting the 'Object variable or With block

variable
not set' error on the line indicated. What am I doing wrong?

Thanks

Regards

Dim OutlookApp As New Outlook.Application
Dim em As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

em = OutlookApp.CreateItemFromTemplate(Template) '<== This line gives

the
error.

With em
em.Recipients.Add ("us***@mydomain.com")
em.Recipients.Add ("us***@mydomain.com")
.Subject = "My Subject"
.Body = "Body Text"
.AttachmentAdd "c:\fiewlname.txt"
.Display (False)
End With

Set em = Nothing


Nov 13 '05 #3

P: n/a
Too bad you didn't show that in what you posted...

I believe it's been pointed out to you somewhere else where you posted the
same question that you need

Set em = OutlookApp.CreateItemFromTemplate(Template)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:41**********************@news.dial.pipex.com. ..
Template is a string variable that has the name & path of the outlook oft
file.

Regards

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:Uq****************@news04.bloor.is.net.cable. rogers.com...
What is Template? If you have a template named "Template", you need to

have
the name in quotes:

em = OutlookApp.CreateItemFromTemplate("Template")

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:41**********************@news.dial.pipex.com. ..
Hi

I am using the below code to generate an outlook message from a template from within access. I am getting the 'Object variable or With block

variable
not set' error on the line indicated. What am I doing wrong?

Thanks

Regards

Dim OutlookApp As New Outlook.Application
Dim em As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

em = OutlookApp.CreateItemFromTemplate(Template) '<== This line
gives the
error.

With em
em.Recipients.Add ("us***@mydomain.com")
em.Recipients.Add ("us***@mydomain.com")
.Subject = "My Subject"
.Body = "Body Text"
.AttachmentAdd "c:\fiewlname.txt"
.Display (False)
End With

Set em = Nothing



Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.