Connecting Tech Pros Worldwide Help | Site Map

Creating outlook message from template

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 13th, 2005, 03:03 AM
John
Guest
 
Posts: n/a
Default 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 ("user1@mydomain.com")
em.Recipients.Add ("user2@mydomain.com")
.Subject = "My Subject"
.Body = "Body Text"
.AttachmentAdd "c:\fiewlname.txt"
.Display (False)
End With

Set em = Nothing



  #2  
Old November 13th, 2005, 03:03 AM
Douglas J. Steele
Guest
 
Posts: n/a
Default Re: Creating outlook message from template

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" <John@nospam.infovis.co.uk> wrote in message
news:414dd12a$0$8516$cc9e4d1f@news.dial.pipex.com. ..[color=blue]
> 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[/color]
variable[color=blue]
> 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[/color]
the[color=blue]
> error.
>
> With em
> em.Recipients.Add ("user1@mydomain.com")
> em.Recipients.Add ("user2@mydomain.com")
> .Subject = "My Subject"
> .Body = "Body Text"
> .AttachmentAdd "c:\fiewlname.txt"
> .Display (False)
> End With
>
> Set em = Nothing
>
>[/color]


  #3  
Old November 13th, 2005, 03:03 AM
John
Guest
 
Posts: n/a
Default Re: Creating outlook message from template

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:Uqk3d.368$7s01.268@news04.bloor.is.net.cable. rogers.com...[color=blue]
> What is Template? If you have a template named "Template", you need to[/color]
have[color=blue]
> the name in quotes:
>
> em = OutlookApp.CreateItemFromTemplate("Template")
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
>
> "John" <John@nospam.infovis.co.uk> wrote in message
> news:414dd12a$0$8516$cc9e4d1f@news.dial.pipex.com. ..[color=green]
> > 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[/color]
> variable[color=green]
> > 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[/color]
> the[color=green]
> > error.
> >
> > With em
> > em.Recipients.Add ("user1@mydomain.com")
> > em.Recipients.Add ("user2@mydomain.com")
> > .Subject = "My Subject"
> > .Body = "Body Text"
> > .AttachmentAdd "c:\fiewlname.txt"
> > .Display (False)
> > End With
> >
> > Set em = Nothing
> >
> >[/color]
>
>[/color]


  #4  
Old November 13th, 2005, 03:03 AM
Douglas J. Steele
Guest
 
Posts: n/a
Default Re: Creating outlook message from template

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" <John@nospam.infovis.co.uk> wrote in message
news:414dd912$0$8504$cc9e4d1f@news.dial.pipex.com. ..[color=blue]
> 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:Uqk3d.368$7s01.268@news04.bloor.is.net.cable. rogers.com...[color=green]
> > What is Template? If you have a template named "Template", you need to[/color]
> have[color=green]
> > the name in quotes:
> >
> > em = OutlookApp.CreateItemFromTemplate("Template")
> >
> > --
> > Doug Steele, Microsoft Access MVP
> > http://I.Am/DougSteele
> > (no e-mails, please!)
> >
> >
> >
> > "John" <John@nospam.infovis.co.uk> wrote in message
> > news:414dd12a$0$8516$cc9e4d1f@news.dial.pipex.com. ..[color=darkred]
> > > Hi
> > >
> > > I am using the below code to generate an outlook message from a[/color][/color][/color]
template[color=blue][color=green][color=darkred]
> > > from within access. I am getting the 'Object variable or With block[/color]
> > variable[color=darkred]
> > > 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[/color][/color][/color]
gives[color=blue][color=green]
> > the[color=darkred]
> > > error.
> > >
> > > With em
> > > em.Recipients.Add ("user1@mydomain.com")
> > > em.Recipients.Add ("user2@mydomain.com")
> > > .Subject = "My Subject"
> > > .Body = "Body Text"
> > > .AttachmentAdd "c:\fiewlname.txt"
> > > .Display (False)
> > > End With
> > >
> > > Set em = Nothing
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.