Add Method (Attachments Collection)

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.


Creates a new attachment in the Attachments, and returns the new attachment as an Attachment object.


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 OlAttachmentTypeconstants: olByReference(4), olByValue(1), or olEmbeddedItem(5).

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

DisplayName   Optional String. The display name of the attachment. Ignored unless Type is set to olByValue.


The following table describes the purpose of each OlAttachmentType constant value.

Constant Use to
olByReference Create a shortcut to an external file
olByValue Embed attachment in the item
olEmbeddedItem Create a shortcut to an Outlook item

When an Attachment is added to the Attachments collection of an item, the Type property of the Attachment will always return olOLE(6) until the item is saved.

To ensure consistent results, always save an item before adding or removing objects in the Attachments collection of the item.