Aspose::Email::Mapi::MapiAttachmentCollection Class Reference

Represents a collection of MapiAttachment objects. More...

Inherits System::Collections::Generic::ListExt< System::SharedPtr< Aspose::Email::Mapi::MapiAttachment > >.

Public Member Functions

 MapiAttachmentCollection ()
 Initializes a new instance of the MapiAttachmentCollection class. More...
 
 MapiAttachmentCollection (System::SharedPtr< MapiMessageItemBase > owner)
 Initializes a new instance of the MapiAttachmentCollection class. More...
 
void Add (System::String name, System::SharedPtr< MapiMessage > msg)
 Adds the new attachment as embedded message. More...
 
void Add (System::String name, System::ArrayPtr< uint8_t > data)
 Adds the new attachment. More...
 
void Add (System::String name, System::String sharedLink, System::String url, System::String providerName)
 Adds the reference attachment. More...
 
void Add (const System::SharedPtr< MapiAttachment > &item) override
 Adds an object to the end of the T:System::Collections::ObjectModel::Collection`1. More...
 
void Insert (int32_t index, const System::SharedPtr< MapiAttachment > &item) override
 Inserts an element into the T:System::Collections::ObjectModel::Collection`1 at the specified index. More...
 
void Insert (int32_t index, System::String name, System::SharedPtr< MapiMessage > msg)
 Inserts a message as attachment into the MapiAttachmentCollection at the specified index. More...
 
void Replace (int32_t index, System::String name, System::SharedPtr< MapiMessage > msg)
 Replaces an element at the specified index. More...
 
void RemoveAt (int32_t index) override
 Removes the element at the specified index of the MapiAttachmentCollection. More...
 
bool Remove (const System::SharedPtr< MapiAttachment > &item) override
 Removes the first occurrence of a specific object from the MapiAttachmentCollection. More...
 
System::String GetNames ()
 Gets the attachment names separated with comma. More...
 
bool ContainsFileName (System::String fileName)
 Determines whether an element with defined name is in the collection. More...
 
System::SharedPtr< MapiAttachmentCreateMapiAttachment (System::String name, System::SharedPtr< MapiMessage > msg, int32_t attachNum)
 
void DeepCopyTo (System::SharedPtr< MapiAttachmentCollection > dest)
 
void SetTemplateWeakPtr (uint32_t argument) override
 

Protected Member Functions

virtual ~MapiAttachmentCollection ()
 

Friends

class Aspose::Email::Mapi::MapiMessage
 
class Aspose::Email::Tnef::TnefAttachment
 
class Aspose::Email::Tools::ForwardMessageBuilder
 

Detailed Description

Represents a collection of MapiAttachment objects.

Constructor & Destructor Documentation

◆ MapiAttachmentCollection() [1/2]

Aspose::Email::Mapi::MapiAttachmentCollection::MapiAttachmentCollection ( )

Initializes a new instance of the MapiAttachmentCollection class.

◆ MapiAttachmentCollection() [2/2]

Aspose::Email::Mapi::MapiAttachmentCollection::MapiAttachmentCollection ( System::SharedPtr< MapiMessageItemBase owner)

Initializes a new instance of the MapiAttachmentCollection class.

Parameters
ownerThe owner message.

◆ ~MapiAttachmentCollection()

virtual Aspose::Email::Mapi::MapiAttachmentCollection::~MapiAttachmentCollection ( )
protectedvirtual

Member Function Documentation

◆ Add() [1/4]

void Aspose::Email::Mapi::MapiAttachmentCollection::Add ( const System::SharedPtr< MapiAttachment > &  item)
override

Adds an object to the end of the T:System::Collections::ObjectModel::Collection`1.

Parameters
itemThe object to be added to the end of the T:System::Collections::ObjectModel::Collection`1. The value can be null for reference types.

◆ Add() [2/4]

void Aspose::Email::Mapi::MapiAttachmentCollection::Add ( System::String  name,
System::ArrayPtr< uint8_t >  data 
)

Adds the new attachment.

Parameters
nameThe name of attachment.
dataThe attachment data.
Exceptions
ArgumentNullExceptionthrows if attachment name is null or empty.
ArgumentNullExceptionthrows if attachment data is null.

◆ Add() [3/4]

void Aspose::Email::Mapi::MapiAttachmentCollection::Add ( System::String  name,
System::SharedPtr< MapiMessage msg 
)

Adds the new attachment as embedded message.

Parameters
nameThe name of attachment.
msgThe MapiMessage that represents the attached message.
Exceptions
ArgumentNullExceptionthrows if message is null.

◆ Add() [4/4]

void Aspose::Email::Mapi::MapiAttachmentCollection::Add ( System::String  name,
System::String  sharedLink,
System::String  url,
System::String  providerName 
)

Adds the reference attachment.

A reference attachment is a type of attachment that includes a link or a reference to a file or item, rather than including the file or item itself in the email message. When the recipients of the email click on the reference attachment, they will be able to access the linked file if they have the appropriate permissions to do so. By using a reference attachment, you can send a smaller email message and ensure that everyone has access to the most up-to-date version of the file or item.

Parameters
nameThe name of attachment.
sharedLinkA fully qualified shared link to the attachment provided by web service manipulating the attachment.
urlA file location.
providerNameA name of reference attachment provider.
Exceptions
ArgumentNullExceptionthrows if attachment name is null or empty.
ArgumentNullExceptionthrows if attachment shared link is null or empty.

This example demonstrates how to add a reference attachment to a message.

[C#]

// Let's say you want to send an email message that includes a link to a Document.pdf file stored on a Google Drive.
// Instead of attaching the document directly to the email message,
// you can create a reference attachment that links to the file on the Google Drive.
// Create a message
var msg = new MapiMessage("from@domain.com", "to@domain.com", "Outlook message file",
"This message is created by Aspose.Email", OutlookMessageFormat.Unicode);
// Add reference attachment
msg.Attachments.Add("Document.pdf",
"https://drive.google.com/file/d/1HJ-M3F2qq1oRrTZ2GZhUdErJNy2CT3DF/",
"https://drive.google.com/drive/my-drive",
"GoogleDrive");
//Also, you can set additional attachment properties
msg.Attachments[0].SetProperty(KnownPropertyList.AttachmentPermissionType, AttachmentPermissionType.AnyoneCanEdit);
msg.Attachments[0].SetProperty(KnownPropertyList.AttachmentOriginalPermissionType, 0);
msg.Attachments[0].SetProperty(KnownPropertyList.AttachmentIsFolder, false);
msg.Attachments[0].SetProperty(KnownPropertyList.AttachmentProviderEndpointUrl, "");
msg.Attachments[0].SetProperty(KnownPropertyList.AttachmentPreviewUrl, "");
msg.Attachments[0].SetProperty(KnownPropertyList.AttachmentThumbnailUrl, "");
// Finally save the message
msg.Save(@"my.msg");

[Visual Basic]

' Let's say you want to send an email message that includes a link to a Document.pdf file stored on a Google Drive.
' Instead of attaching the document directly to the email message,
' you can create a reference attachment that links to the file on the Google Drive.
' Create a message
Dim msg As New MapiMessage("from@domain.com", "to@domain.com", "Outlook message file", "This message is created by Aspose.Email", OutlookMessageFormat.Unicode)
' Add reference attachment
msg.Attachments.Add("Document.pdf", "https://drive.google.com/file/d/1HJ-M3F2qq1oRrTZ2GZhUdErJNy2CT3DF/", "https://drive.google.com/drive/my-drive", "GoogleDrive")
' Also, you can set additional attachment properties
msg.Attachments(0).SetProperty(KnownPropertyList.AttachmentPermissionType, AttachmentPermissionType.AnyoneCanEdit)
msg.Attachments(0).SetProperty(KnownPropertyList.AttachmentOriginalPermissionType, AttachmentPermissionType.None)
msg.Attachments(0).SetProperty(KnownPropertyList.AttachmentIsFolder, False)
msg.Attachments(0).SetProperty(KnownPropertyList.AttachmentProviderEndpointUrl, "")
msg.Attachments(0).SetProperty(KnownPropertyList.AttachmentPreviewUrl, "")
msg.Attachments(0).SetProperty(KnownPropertyList.AttachmentThumbnailUrl, "")
' Finally save the message
msg.Save("my.msg")

◆ ContainsFileName()

bool Aspose::Email::Mapi::MapiAttachmentCollection::ContainsFileName ( System::String  fileName)

Determines whether an element with defined name is in the collection.

Parameters
fileName
Returns
true if item is found in the collections otherwise, false.

◆ CreateMapiAttachment()

System::SharedPtr<MapiAttachment> Aspose::Email::Mapi::MapiAttachmentCollection::CreateMapiAttachment ( System::String  name,
System::SharedPtr< MapiMessage msg,
int32_t  attachNum 
)

◆ DeepCopyTo()

void Aspose::Email::Mapi::MapiAttachmentCollection::DeepCopyTo ( System::SharedPtr< MapiAttachmentCollection dest)

◆ GetNames()

System::String Aspose::Email::Mapi::MapiAttachmentCollection::GetNames ( )

Gets the attachment names separated with comma.

Returns

◆ Insert() [1/2]

void Aspose::Email::Mapi::MapiAttachmentCollection::Insert ( int32_t  index,
const System::SharedPtr< MapiAttachment > &  item 
)
override

Inserts an element into the T:System::Collections::ObjectModel::Collection`1 at the specified index.

Parameters
indexThe zero-based index at which item should be inserted.
itemThe object to insert. The value can be null for reference types.
Exceptions
T:System::ArgumentOutOfRangeExceptionindex is less than zero.

-or-

index is greater than P:System::Collections::ObjectModel::Collection`1::Count.

◆ Insert() [2/2]

void Aspose::Email::Mapi::MapiAttachmentCollection::Insert ( int32_t  index,
System::String  name,
System::SharedPtr< MapiMessage msg 
)

Inserts a message as attachment into the MapiAttachmentCollection at the specified index.

Parameters
indexThe zero-based index at which should be inserted.
nameThe name of attachment.
msgThe MapiMessage that represents the attached message.
Exceptions
ArgumentNullExceptionthrows if message is null.

◆ Remove()

bool Aspose::Email::Mapi::MapiAttachmentCollection::Remove ( const System::SharedPtr< MapiAttachment > &  item)
override

Removes the first occurrence of a specific object from the MapiAttachmentCollection.

Parameters
itemThe object to remove from the MapiAttachmentCollection.
Returns
true if item is successfully removed; otherwise, false.

◆ RemoveAt()

void Aspose::Email::Mapi::MapiAttachmentCollection::RemoveAt ( int32_t  index)
override

Removes the element at the specified index of the MapiAttachmentCollection.

Parameters
indexhe zero-based index of the element to remove.

◆ Replace()

void Aspose::Email::Mapi::MapiAttachmentCollection::Replace ( int32_t  index,
System::String  name,
System::SharedPtr< MapiMessage msg 
)

Replaces an element at the specified index.

Parameters
indexThe zero-based index at which should be replaced.
nameThe name of attachment.
msgThe MapiMessage that represents the attached message.
Exceptions
ArgumentNullExceptionthrows if message is null.

◆ SetTemplateWeakPtr()

void Aspose::Email::Mapi::MapiAttachmentCollection::SetTemplateWeakPtr ( uint32_t  argument)
override

Friends And Related Function Documentation

◆ Aspose::Email::Mapi::MapiMessage

friend class Aspose::Email::Mapi::MapiMessage
friend

◆ Aspose::Email::Tnef::TnefAttachment

friend class Aspose::Email::Tnef::TnefAttachment
friend

◆ Aspose::Email::Tools::ForwardMessageBuilder

AttachmentPermissionType
The permission type data associated with a web reference attachment.
Definition: AttachmentPermissionType.h:16
void Add(System::String name, System::SharedPtr< MapiMessage > msg)
Adds the new attachment as embedded message.
OutlookMessageFormat
Represents outlook message format.
Definition: OutlookMessageFormat.h:23