Class MapiAttachmentCollection
Contents
[
Hide
]MapiAttachmentCollection class
The attachments of an Outlook item.
public class MapiAttachmentCollection : List<MapiAttachment>
Constructors
| Name | Description |
|---|---|
| MapiAttachmentCollection() | Initializes a new instance of the MapiAttachmentCollection class. |
| MapiAttachmentCollection(MapiMessageItemBase) | Initializes a new instance of the MapiAttachmentCollection class that belongs to the specified item. |
Methods
| Name | Description |
|---|---|
| Add(MapiAttachment) | Adds an existing attachment to the end of the collection. |
| Add(string, byte[]) | Adds a file attachment with the content in memory. |
| Add(string, MapiMessage) | Attaches a message as an embedded message. |
| Add(string, ReferenceAttachmentOptions) | Adds a reference attachment to the collection using the specified name and configuration options. |
| Add(string, Stream) | Adds a new attachment whose content is read from a stream. |
| Add(string, Stream, bool) | Adds a new attachment whose content is read from a stream. |
| AddFile(string) | Adds a new attachment reading its content from a file. The file name is used as the display name of the attachment. |
| AddFile(string, string) | Adds a new attachment reading its content from a file. |
| Insert(int, MapiAttachment) | Inserts an attachment at the specified position. |
| Insert(int, string, MapiMessage) | Inserts a message as an embedded attachment at the specified position. |
| Remove(MapiAttachment) | Removes the first occurrence of the attachment from the collection. |
| RemoveAt(int) | Removes the attachment at the specified position. |
| Replace(int, string, MapiMessage) | Replaces the attachment at the specified position with an embedded message. |
Remarks
Returned by Attachments. Besides the list operations, it adds files from memory, from a stream or from disk, embedded messages and reference (cloud) attachments.
Examples
This example attaches a file from disk, a file from memory and another message.
[C#]
using (var msg = new MapiMessage("from@domain.com", "to@domain.com", "Report", "See the attachments."))
{
// the file is read when the message is saved
msg.Attachments.AddFile("report.pdf");
msg.Attachments.Add("notes.txt", Encoding.UTF8.GetBytes("Notes for the report"));
var original = MapiMessage.Load("original.msg");
msg.Attachments.Add("Original message", original);
msg.Save("report.msg");
}
[Visual Basic]
Using msg = New MapiMessage("from@domain.com", "to@domain.com", "Report", "See the attachments.")
' the file is read when the message is saved
msg.Attachments.AddFile("report.pdf")
msg.Attachments.Add("notes.txt", Encoding.UTF8.GetBytes("Notes for the report"))
Dim original = MapiMessage.Load("original.msg")
msg.Attachments.Add("Original message", original)
msg.Save("report.msg")
End Using
See Also
- class MapiAttachment
- namespace Aspose.Email.Mapi
- assembly Aspose.Email