473,395 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Creating outlook message from template

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
3 4332
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: CReds | last post by:
OK, I am little down right now. We have spent the better part of six months getting our website programmed and tested. We finally went live last week. This week, we get a e-mail from another...
1
by: elziko | last post by:
Everytime I use this code: Dim objOutlook As New Outlook.Application Dim objNameSpace As Outlook.NameSpace Dim objFolder As Outlook.MAPIFolder Dim objJournalEntry As Outlook.JournalItem =...
2
by: John | last post by:
Hi I am trying to find the way to create an email in outlook. I am using the code given at the end. It works fine the first time but calling the code second time gives the following error; ...
0
by: Jason James | last post by:
Hi all, does anyone have any suggestions as to the steps involved in creating a DL using VB.Net. I have some Outlook automation experience but I'm not sure what the objects are that I should...
0
by: Mads Westen | last post by:
Hi, I'm using the code under here to make a mail in Outlook and display it. I would like to be able to use the standard template/stationary I use in Outlook. It's HTML with som tables, pictures...
3
by: Jeff | last post by:
I am trying to send emails from my application (not using a plugin, that will come later), I can create an email and add attachments. I can fill in the body etc. Word works for the editor. So...
9
by: ARC | last post by:
In case anyone has ran into this yet. The following code used to work with older versions of the MS Outlook library, but would error out in 2007: Dim objOutlook As Outlook.Application Dim...
0
by: Ben Grimwade | last post by:
Hi, im developing an Application that integrates with Outlook by creating an appointment in there calender. The code in question is below Dim appt As Outlook.AppointmentItem obj =...
5
by: John | last post by:
Hi I have an Outlook add-in solution which includes a setup project. If I install the Outlook add-in by right clicking on the setup project and sleeting Install then the add-in gets installed...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.