MapiAttachment
Contents
[
Hide
]MapiAttachment class
Inherits: Aspose::Email::Mapi::MapiPropertyContainer
Represents a message attachment.
This class encapsulates an attachment, providing methods to access and manipulate its properties.
This code example loads a message from a file and iterates over each attachment. If an attachment is inline, it prints its display name. If not, it checks if the attachment is an embedded message. If so, it saves the attachment to a memory stream. If not, it saves to a specified path.
// Load the MAPI message from the specified file
var msg = MapiMessage.Load("source.msg");
// Iterate over each attachment in the MAPI message
foreach (var mapiAttachment in msg.Attachments)
{
// Check if the attachment is inline
if (mapiAttachment.IsInline)
{
// If inline, print its display name
Console.WriteLine($"Inline: {mapiAttachment.DisplayName}");
}
else
{
// If not inline
// Check if the attachment contains an embedded message
if (mapiAttachment.ObjectData != null && mapiAttachment.ObjectData.IsOutlookMessage)
{
// If it's an embedded message
// Save the attachment to a memory stream
using (MemoryStream ms = new MemoryStream())
{
mapiAttachment.Save(ms);
ms.Position = 0;
// Load the embedded message from the memory stream
var embeddedMessage = MapiMessage.Load(ms);
}
}
else
{
// If it's not an embedded message
// Save the attachment to the specified path
mapiAttachment.Save(Path.Combine(path, mapiAttachment.LongFileName));
}
}
}
' Load the MAPI message from the specified file
Dim msg = MapiMessage.Load("source.msg")
' Iterate over each attachment in the MAPI message
For Each mapiAttachment In msg.Attachments
' Check if the attachment is inline
If mapiAttachment.IsInline Then
' If inline, print its display name
Console.WriteLine($"Inline: {mapiAttachment.DisplayName}")
Else
' If not inline
' Check if the attachment contains an embedded message
If mapiAttachment.ObjectData IsNot Nothing AndAlso mapiAttachment.ObjectData.IsOutlookMessage Then
' If it's an embedded message
' Save the attachment to a memory stream
Using ms As New MemoryStream()
mapiAttachment.Save(ms)
ms.Position = 0
' Load the embedded message from the memory stream
Dim embeddedMessage = MapiMessage.Load(ms)
End Using
Else
' If it's not an embedded message
' Save the attachment to the specified path
mapiAttachment.Save(Path.Combine(path, mapiAttachment.LongFileName))
End If
End If
Next
Constructors
| Name | Description |
|---|---|
| MapiAttachment (8 overloads) | Initializes a new instance of the MapiAttachment class. |
Methods
| Name | Description |
|---|---|
| Clone | |
| CreateMapiNode | Creates the mapi node. |
| get_BinaryData | Gets binary attachment data. |
| get_Content | Gets the content. |
| get_ContentId | |
| get_DisplayName | Gets the display name of the ole object in an attachment. |
| get_Extension | Gets a filename extension that indicates the document type of an attachment. |
| get_FileName | Gets an attachment’s base filename and extension, excluding path. |
| get_Hidden | |
| get_IsInline | Gets a value indicating whether the attachment is inline or regular. If inline returns true, otherwise false. |
| get_IsReference | Gets a value indicating whether the attachment is stored as a reference rather than being embedded in the email. |
| get_ItemId | The item id, uses with a server |
| get_LongFileName | Gets an attachment’s long filename and extension, excluding path. |
| get_MimeTag | Gets formatting information about a Multipurpose Internet Mail Extensions (MIME) attachment. |
| get_NamedProperties | Gets the named properties of message. |
| get_ObjectData | Gets an attachment object typically accessed through the OLE IStorage interface. |
| get_PropertyStream | Gets the property stream. |
| get_SubStorages | Gets the sub storages. |
| GetProperty | Gets MAPI property by property descriptor. |
| GetSize | Gets the size of the attachment. Contains the sum, in bytes, of the sizes of all properties on an attachment. The sum contained in PR_ATTACH_SIZE property includes the size of the PR_ATTACH_DATA_BIN or PR_ATTACH_DATA_OBJ property. |
| LoadFromTnef (2 overloads) | Load MapiAttachment from stream with tnef content. |
| RemoveProperty | Provides correctly removing property from all collections. |
| Save (2 overloads) | Save attachment content. |
| SaveInternal | Save attachment content. |
| SaveToTnef (2 overloads) | Save attachment to tnef content. |
| SaveToTnefInternal | |
| set_BinaryData | Sets binary attachment data. |
| set_DisplayName | Gets the display name of the ole object in an attachment. |
| set_ItemId | The item id, uses with a server |
| SetNamedPropertyMapping | Sets the named property mapping. |
| SetOwner | Sets the owner. |
| SetProperty (2 overloads) | Sets the property. |
| ToMapiMessage | |
| ToMemoryStream | |
| TryGetNamedProperty | If MapiNamedPropertyMappingStorage is available, initializes and returns MapiNamedProperty , otherwise null. |
| Aspose::Email::Clients::Graph::GraphClientV1 | |
| Aspose::Email::Clients::Graph::V1::Commands::CreateAttachmentCommand | |
| Aspose::Email::Clients::Graph::V1::Commands::CreateTaskAttachmentCommand | |
| Aspose::Email::Clients::Graph::V1::Commands::GetAttachmentCommand | |
| Aspose::Email::Clients::Graph::V1::Commands::GetTaskAttachmentCommand | |
| Aspose::Email::Clients::Graph::V1::Commands::ListAttachmentsCommand | |
| Aspose::Email::Clients::Graph::V1::Commands::ListTaskAttachmentsCommand | |
| namedPropertyMappingStorage | The named property mapping storage. |