Export (0) Print
Expand All

Attachments.Add method

Creates a new attachment in the Attachments collection.

Namespace:  Microsoft.Office.Interop.Outlook
Assembly:  Microsoft.Office.Interop.Outlook (in Microsoft.Office.Interop.Outlook.dll)

[DispIdAttribute()]
Attachment Add(
	Object Source,
	Object Type,
	Object Position,
	Object DisplayName
)

Parameters

Source
Type: System.Object

The source of the attachment. This can be a file (represented by the full file system path with a file name) or an Outlook item that constitutes the attachment.

Type
Type: System.Object

The type of the attachment. Can be one of the OlAttachmentType constants.

Position
Type: System.Object

This parameter applies only to e-mail messages using Microsoft Outlook Rich Text format: it is the position where the attachment should be placed within the body text of the message. A value of 1 for the Position parameter specifies that the attachment should be positioned at the beginning of the message body. A value 'n' greater than the number of characters in the body of the e-mail item specifies that the attachment should be placed at the end. A value of 0 makes the attachment hidden.

DisplayName
Type: System.Object

This parameter applies only if the mail item is in Rich Text format and Type is set to olByValue: the name is displayed in an Inspector object for the attachment or when viewing the properties of the attachment. If the mail item is in Plain Text or HTML format, then the attachment is displayed using the file name in the Source parameter.

Return value

Type: Microsoft.Office.Interop.Outlook.Attachment
An Attachment object that represents the new attachment.

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.

Show:
© 2015 Microsoft