RemoveAttachments

MapiMessage.RemoveAttachments method

Removes all of the attachments from the specified Outlook Message files.

public static MapiAttachmentCollection RemoveAttachments(string path)
Parameter Type Description
path String The name of the Outlook Message file.

Return Value

The attachments collection.

Examples

The following exmaple demonstrates how to destroy attachments in Outlook Message files.

[C#]

//Remove attachments from Outlook Message files
MapiAttachmentCollection attachments = MapiMessage.RemoveAttachments(@"c:\outlookmessage.msg");

//Attachments
foreach(MapiAttachment att in attachments)
{
   Console.WriteLine("Attachment Name:"+att.FileName);
   att.Save(att.FileName);
}

[Visual Basic]

'Remove attachments from Outlook Message files
MapiAttachmentCollection attachments = MapiMessage.RemoveAttachments("c:\outlookmessage.msg");

'Attachments 
For Each att As MapiAttachment In msg.Attachments 
     Console.WriteLine("Attachment Name:" + att.FileName) 
     att.Save(att.FileName) 
Next

See Also