Follow us on Twitter
Follow us in Facebook
Office Dev Content
SharePoint Dev Content
Blogs for Office developers > Office and Office 365 dev blog
Attaching a file to a Microsoft Outlook mail item is one of the most popular customer actions in Outlook.
Naturally, many power users also ask how to do this programmatically. The Outlook object model provides the Attachment object, Attachments.Add method, and an Attachments property for each of the Outlook item objects (for example, mail, appointment, contact, meeting, and task items), to support adding an attachment to an Outlook item. You can attach a copy of a file, an Outlook item like a message or contact, or an Object Linking and Embedding (OLE) object to an Outlook item. In particular, if you are attaching a file to a mail item that uses Rich Text Format (RTF), you can also specify the location to place the attachment in the body of the mail message, and the display name of the attachment.
Ken Getz, a Microsoft MVP and an expert in a multitude of technologies including Microsoft Office, Microsoft Visual Studio, Visual Basic, and C#, recently contributed a set of four code samples to illustrate a few tasks around attachments.
The sample code in these topics is presented in both C# and Visual Basic. Hope you can adapt the code to suit your scenarios.