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)
Syntax
'Declaration
<DispIdAttribute()> _
Function Add ( _
Source As Object, _
Type As Object, _
Position As Object, _
DisplayName As Object _
) As Attachment
'Usage
Dim instance As Attachments
Dim Source As Object
Dim Type As Object
Dim Position As Object
Dim DisplayName As Object
Dim returnValue As Attachment
returnValue = instance.Add(Source, Type, _
Position, DisplayName)
[DispIdAttribute()]
Attachment Add(
Object Source,
Object Type,
Object Position,
Object DisplayName
)
Parameters
Source
Type: System.ObjectThe 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.ObjectThe type of the attachment. Can be one of the OlAttachmentType constants.
Position
Type: System.ObjectThis 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.ObjectThis 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.
Remarks
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.
See Also
Reference
Microsoft.Office.Interop.Outlook Namespace
Other Resources
How to: Attach a File to a Mail Item
How to: Attach an Outlook Contact Item to an Email Message
How to: Limit the Size of an Attachment to an Outlook Email Message
How to: Modify an Attachment of an Outlook Email Message
How to: Create a Mail Item, Attach a Report, and Send the Mail Item to the User's Manager