473,769 Members | 2,365 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Applica tion
Dim em As Outlook.MailIte m
Dim objOutlookRecip As Outlook.Recipie nt

em = OutlookApp.Crea teItemFromTempl ate(Template) '<== This line gives the
error.

With em
em.Recipients.A dd ("us***@mydomai n.com")
em.Recipients.A dd ("us***@mydomai n.com")
.Subject = "My Subject"
.Body = "Body Text"
.AttachmentAdd "c:\fiewlname.t xt"
.Display (False)
End With

Set em = Nothing
Nov 13 '05 #1
3 4355
What is Template? If you have a template named "Template", you need to have
the name in quotes:

em = OutlookApp.Crea teItemFromTempl ate("Template")

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

"John" <Jo**@nospam.in fovis.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.Applica tion
Dim em As Outlook.MailIte m
Dim objOutlookRecip As Outlook.Recipie nt

em = OutlookApp.Crea teItemFromTempl ate(Template) '<== This line gives the error.

With em
em.Recipients.A dd ("us***@mydomai n.com")
em.Recipients.A dd ("us***@mydomai n.com")
.Subject = "My Subject"
.Body = "Body Text"
.AttachmentAdd "c:\fiewlname.t xt"
.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_djsteel e@NOSPAM_canada .com> wrote in message
news:Uq******** ********@news04 .bloor.is.net.c able.rogers.com ...
What is Template? If you have a template named "Template", you need to have the name in quotes:

em = OutlookApp.Crea teItemFromTempl ate("Template")

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

"John" <Jo**@nospam.in fovis.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.Applica tion
Dim em As Outlook.MailIte m
Dim objOutlookRecip As Outlook.Recipie nt

em = OutlookApp.Crea teItemFromTempl ate(Template) '<== This line gives

the
error.

With em
em.Recipients.A dd ("us***@mydomai n.com")
em.Recipients.A dd ("us***@mydomai n.com")
.Subject = "My Subject"
.Body = "Body Text"
.AttachmentAdd "c:\fiewlname.t xt"
.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.Crea teItemFromTempl ate(Template)

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

"John" <Jo**@nospam.in fovis.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_djsteel e@NOSPAM_canada .com> wrote in message
news:Uq******** ********@news04 .bloor.is.net.c able.rogers.com ...
What is Template? If you have a template named "Template", you need to

have
the name in quotes:

em = OutlookApp.Crea teItemFromTempl ate("Template")

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

"John" <Jo**@nospam.in fovis.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.Applica tion
Dim em As Outlook.MailIte m
Dim objOutlookRecip As Outlook.Recipie nt

em = OutlookApp.Crea teItemFromTempl ate(Template) '<== This line
gives the
error.

With em
em.Recipients.A dd ("us***@mydomai n.com")
em.Recipients.A dd ("us***@mydomai n.com")
.Subject = "My Subject"
.Body = "Body Text"
.AttachmentAdd "c:\fiewlname.t xt"
.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
2167
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 department stating we must submit reports via a Outlook Template. This is a good thing overall. The website I have, pretty much asks the same questions as they want, but they want us to use the template. Can I incorporate the template using CDO...
1
3760
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 = DirectCast(objOutlook.CreateItem(Outlook.OlItemType.olJournalItem), Outlook.JournalItem) objJournalEntry.Subject = "TEST!" objNameSpace = objOutlook.GetNamespace("MAPI")
2
2238
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; Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW can...
0
1742
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 be creating. There is a distribution list item object, but no dsitribution list object to contain the items!
0
1160
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 and stuff. How can I do that? The mailcode:
3
10650
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 mostly what I want. My issue is I would like to retain the signature block that exists when I insert my body into the message. Any help would be appreciated. Here is the code I am using: //Initialize the envelope values. string strTo =...
9
2248
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 objOutlookMsg As Outlook.MailItem Dim objOutlookRecip As Outlook.Recipient Dim objOutlookAttach As Outlook.Attachment Set objOutlook = CreateObject("Outlook.Application") ' Create the message. Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
0
1332
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 = diary.Items.Find(" = " & Chr(34) & idCheck & Chr(34)) If obj Is Nothing Then 'Now create a new appointment in the user's diary appt = m_OutlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem) Else
5
2210
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 fine in Outlook. However if I use the setup generated in the setup project Release folder then even though setup runs and finishes, the Outlook Add-in does not appear in Outlook. What is the problem and how can I fix it? Thanks
0
9586
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9990
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3956
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.