MapiAttachment

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

NameDescription
MapiAttachment (8 overloads)Initializes a new instance of the MapiAttachment class.

Methods

NameDescription
Clone
CreateMapiNodeCreates the mapi node.
get_BinaryDataGets binary attachment data.
get_ContentGets the content.
get_ContentId
get_DisplayNameGets the display name of the ole object in an attachment.
get_ExtensionGets a filename extension that indicates the document type of an attachment.
get_FileNameGets an attachment’s base filename and extension, excluding path.
get_Hidden
get_IsInlineGets a value indicating whether the attachment is inline or regular. If inline returns true, otherwise false.
get_IsReferenceGets a value indicating whether the attachment is stored as a reference rather than being embedded in the email.
get_ItemIdThe item id, uses with a server
get_LongFileNameGets an attachment’s long filename and extension, excluding path.
get_MimeTagGets formatting information about a Multipurpose Internet Mail Extensions (MIME) attachment.
get_NamedPropertiesGets the named properties of message.
get_ObjectDataGets an attachment object typically accessed through the OLE IStorage interface.
get_PropertyStreamGets the property stream.
get_SubStoragesGets the sub storages.
GetPropertyGets MAPI property by property descriptor.
GetSizeGets 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.
RemovePropertyProvides correctly removing property from all collections.
Save (2 overloads)Save attachment content.
SaveInternalSave attachment content.
SaveToTnef (2 overloads)Save attachment to tnef content.
SaveToTnefInternal
set_BinaryDataSets binary attachment data.
set_DisplayNameGets the display name of the ole object in an attachment.
set_ItemIdThe item id, uses with a server
SetNamedPropertyMappingSets the named property mapping.
SetOwnerSets the owner.
SetProperty (2 overloads)Sets the property.
ToMapiMessage
ToMemoryStream
TryGetNamedPropertyIf 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
namedPropertyMappingStorageThe named property mapping storage.