PDA

Click to See Complete Forum and Search --> : outlook


Mark Sreeves
Nov 8th, 1999, 06:13 PM
I just tried to add .Attachments to an outlook object.

Can anyone tell me what the correect syntax is?

objOutlookMsg.Attachments = "C:\test.txt"

raises the error "One or more parameters are incorrect"

Thaks in advance etc.

------------------
Mark Sreeves
Analyst Programmer

Mark.Sreeves@Softlab.co.uk
A BMW Group Company

Ishamel
Nov 8th, 1999, 07:01 PM
Mark,

I think this is what you are after. I've not tested it, so you might have to tweak it slightly.


Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myAttachments = myItem.Attachments
myAttachments.Add "C:\Test.txt", _
olByValue, 1, "Test File"

Mark Sreeves
Nov 8th, 1999, 07:12 PM
Thanks for that Ishamel!


------------------
Mark Sreeves
Analyst Programmer

Mark.Sreeves@Softlab.co.uk
A BMW Group Company

Ishamel
Nov 8th, 1999, 07:16 PM
Here's what the help file has to say incase you need more info.

Syntax - objAttachments.Add(Source, [Type], [Position], [DisplayName])

objAttachments - Required. An expression that returns an Attachments collection object.

Source - Required Variant. The file (represented by the full path and file name) or item that constitutes the attachment.

Type - Optional Long. The type of attachment. Can be one of the following OlAttachmentType constants: olByReference(4), olByValue(1), olEmbeddedItem(5), or olOLE(6).

Position - Optional Long. The position of the attachment within the body text of the message.

DisplayName - Optional String. The display name of the attachment.