共用方式為


Attachment Object (Outlook)

Represents a document or link to a document contained in an Outlook item.

Remarks

Use Attachments (index), where index is the index number, to return a single Attachment object.

Use the Add method to add an attachment to an item.

Example

The following Visual Basic for Applications (VBA) example creates a new mail message, attaches Q496.xlsx as an attachment (not a link), assigns the attachment a descriptive caption, and displays the mail message with this attachment. This example assumes that the specified spreadsheet, Q496.xlsx, exists in the specified path, D:\Documents.

Sub AddAttachment() 
 
 Dim myItem As Outlook.MailItem 
 
 Dim myAttachments As Outlook.Attachments 
 
 
 
 Set myItem = Application.CreateItem(olMailItem) 
 
 Set myAttachments = myItem.Attachments 
 
 myAttachments.Add "D:\Documents\Q496.xlsx", _ 
 
 olByValue, 1, "4th Quarter 1996 Results Chart" 
 
 myItem.Display 
 
End Sub

See Also

Concepts

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

Outlook Object Model Reference

Attachment Object Members