I'm doing a feature in outlook addin, when I open a email item, I am able to create a task item based on the email item, my code now is able to copy all the data in the mail item and put it into the task item, the only problem I encounter is that I am not able to copy the attachments in the email item into the task item. How am I able to do that

Below is the code I already wrote:

Outlook.Application outlookApp = new Outlook.Application();

object item = outlookApp.ActiveExplorer().Selection[1];

Outlook.MailItem mail = (Outlook.MailItem)item;


Outlook.MAPIFolder tasksFolder = outlookApp.GetNamespace("MAPI").GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderTasks);

Outlook.TaskItem taskItem = (Outlook.TaskItem)tasksFolder.Items.Add(Outlook.OlItemType.olTaskItem);

taskItem.Subject = mail.Subject;

taskItem.Body = mail.Body;



Re: Visual Studio Tools for Office Copy attachments from a email item and put in a task item in outlook.

Sue Mosher - Outlook MVP

Save each attachment to a temporary location using the Attachment.SaveAsFile, then call taskItem.Attachments.Add to add each saved file as an attachment.