attach file with automation in Outlook

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My program;
#define mailitem 0
oOutLookObject = CreateObject("Outlook.Application")
oEmailItem = oOutLookObject.CreateItem(mailitem)
WITH oEmailItem
.Recipients.Add([[email protected]])
.Subject = [TEST]
.cc=[ ]
.Importance=1
.Body = [ ] ??????? && here i need to attach a file *.msg or *.dot
ENDWITH
release oEmailItem,oOutLookObject,pcTekst,pcOnderwerp

What's the problem ?

I want to attach a file in outlook with a program, my program works but it's
only send tekst to Outlook. So I think I need another statement in place of
".body"
I need to send files *.msg or Outlook template files.
I looked everywhere, burt I can't find a solution.
So i will be very pleased if someone could help me.
 
You must not have used the object browser (F2 in VBA) or Outlook developer Help to look this up. If you had, you would have seen the Attachments collection:

.Attachments.Add c:\myfile.msg, 1

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


huub van helderen said:
My program;
#define mailitem 0
oOutLookObject = CreateObject("Outlook.Application")
oEmailItem = oOutLookObject.CreateItem(mailitem)
WITH oEmailItem
.Recipients.Add([[email protected]])
.Subject = [TEST]
.cc=[ ]
.Importance=1
.Body = [ ] ??????? && here i need to attach a file *.msg or *.dot
ENDWITH
release oEmailItem,oOutLookObject,pcTekst,pcOnderwerp

What's the problem ?

I want to attach a file in outlook with a program, my program works but it's
only send tekst to Outlook. So I think I need another statement in place of
".body"
I need to send files *.msg or Outlook template files.
I looked everywhere, burt I can't find a solution.
So i will be very pleased if someone could help me.
 
I,ve seen it, but i don't want to send it as an attatchment but I need a
solution to place a file as contents in the body (JPG MSG or DOT template
file), in other words
I think I need a statement like .bodyinsert or something like that.

Thanks for response

--
huub


Sue Mosher said:
You must not have used the object browser (F2 in VBA) or Outlook developer Help to look this up. If you had, you would have seen the Attachments collection:

.Attachments.Add c:\myfile.msg, 1

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


huub van helderen said:
My program;
#define mailitem 0
oOutLookObject = CreateObject("Outlook.Application")
oEmailItem = oOutLookObject.CreateItem(mailitem)
WITH oEmailItem
.Recipients.Add([[email protected]])
.Subject = [TEST]
.cc=[ ]
.Importance=1
.Body = [ ] ??????? && here i need to attach a file *.msg or *.dot
ENDWITH
release oEmailItem,oOutLookObject,pcTekst,pcOnderwerp

What's the problem ?

I want to attach a file in outlook with a program, my program works but it's
only send tekst to Outlook. So I think I need another statement in place of
".body"
I need to send files *.msg or Outlook template files.
I looked everywhere, burt I can't find a solution.
So i will be very pleased if someone could help me.
 
If you didn't want to send an attachment, then why did you say "I want to attach a file."

The techniques used to insert content from a file into the body of the message vary with the content. For a .jpg image, see http://www.outlookcode.com/d/code/htmlimg.htm. For an .msg file, use the Application.CreateItem from template method. For a .dot Word template, use Word's Application.Documents.Add method to create a new document from the template and then use the technique shown at http://www.outlookcode.com/codedetail.aspx?id=1333 to use that document to create a message body.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


huub van helderen said:
I,ve seen it, but i don't want to send it as an attatchment but I need a
solution to place a file as contents in the body (JPG MSG or DOT template
file), in other words
I think I need a statement like .bodyinsert or something like that.

Thanks for response

--
huub


Sue Mosher said:
You must not have used the object browser (F2 in VBA) or Outlook developer Help to look this up. If you had, you would have seen the Attachments collection:

.Attachments.Add c:\myfile.msg, 1

huub van helderen said:
My program;

#define mailitem 0
oOutLookObject = CreateObject("Outlook.Application")
oEmailItem = oOutLookObject.CreateItem(mailitem)
WITH oEmailItem
.Recipients.Add([[email protected]])
.Subject = [TEST]
.cc=[ ]
.Importance=1
.Body = [ ] ??????? && here i need to attach a file *.msg or *.dot
ENDWITH
release oEmailItem,oOutLookObject,pcTekst,pcOnderwerp


What's the problem ?

I want to attach a file in outlook with a program, my program works but it's
only send tekst to Outlook. So I think I need another statement in place of
".body"
I need to send files *.msg or Outlook template files.
I looked everywhere, burt I can't find a solution.
So i will be very pleased if someone could help me.
 
Sorry Sue, it must be my poor English, but still I thank you for your help.
--
huub


Sue Mosher said:
If you didn't want to send an attachment, then why did you say "I want to attach a file."

The techniques used to insert content from a file into the body of the message vary with the content. For a .jpg image, see http://www.outlookcode.com/d/code/htmlimg.htm. For an .msg file, use the Application.CreateItem from template method. For a .dot Word template, use Word's Application.Documents.Add method to create a new document from the template and then use the technique shown at http://www.outlookcode.com/codedetail.aspx?id=1333 to use that document to create a message body.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


huub van helderen said:
I,ve seen it, but i don't want to send it as an attatchment but I need a
solution to place a file as contents in the body (JPG MSG or DOT template
file), in other words
I think I need a statement like .bodyinsert or something like that.

Thanks for response

--
huub


Sue Mosher said:
You must not have used the object browser (F2 in VBA) or Outlook developer Help to look this up. If you had, you would have seen the Attachments collection:

.Attachments.Add c:\myfile.msg, 1

My program;

#define mailitem 0
oOutLookObject = CreateObject("Outlook.Application")
oEmailItem = oOutLookObject.CreateItem(mailitem)
WITH oEmailItem
.Recipients.Add([[email protected]])
.Subject = [TEST]
.cc=[ ]
.Importance=1
.Body = [ ] ??????? && here i need to attach a file *.msg or *.dot
ENDWITH
release oEmailItem,oOutLookObject,pcTekst,pcOnderwerp


What's the problem ?

I want to attach a file in outlook with a program, my program works but it's
only send tekst to Outlook. So I think I need another statement in place of
".body"
I need to send files *.msg or Outlook template files.
I looked everywhere, burt I can't find a solution.
So i will be very pleased if someone could help me.
 
Back
Top