Represents an e-mail attachment. More...

Inherits Aspose::Email::AttachmentBase, and Aspose::Email::IPreferredTextEncodingProvider.

Inherited by Aspose::Email::ReferenceAttachment.

Public Member Functions

bool get_IsTnef ()
 Gets a value indicating whether the attachment is TNEF formatted message. More...
 
bool get_IsEmbeddedMessage ()
 Gets a value indicating whether the attachment is an embedded message. More...
 
System::String get_Name ()
 Gets an attachment name More...
 
void set_Name (System::String value)
 Sets an attachment name More...
 
System::SharedPtr< System::Text::Encoding > get_NameEncoding ()
 Gets an encoding of attachment name More...
 
void set_NameEncoding (System::SharedPtr< System::Text::Encoding > value)
 Sets an encoding of attachment name More...
 
System::SharedPtr< Aspose::Email::Mime::ContentDispositionget_ContentDisposition ()
 Gets Content-Disposition header More...
 
bool get_IsUri () const
 Gets a value indicating whether attachment is URI-attachment. More...
 
System::SharedPtr< ObjectIdentifierget_Id () const
 Object identifier More...
 
System::String get_CreatedName () const
 Created name from subject in case when attacment is message/rfc822 More...
 
void set_CreatedName (System::String value)
 Created name from subject in case when attacment is message/rfc822 More...
 
System::SharedPtr< System::Text::Encoding > get_PreferredTextEncoding () override
 Gets a preferred text encoding More...
 
void set_PreferredTextEncoding (System::SharedPtr< System::Text::Encoding > value) override
 Sets a preferred text encoding More...
 
 Attachment (System::String fileName)
 Initializes a new instance of the Attachment class. More...
 
 Attachment (System::String fileName, System::String mediaType)
 Initializes a new instance of the Attachment class. More...
 
 Attachment (System::String fileName, System::SharedPtr< Aspose::Email::Mime::ContentType > contentType)
 Initializes a new instance of the Attachment class. More...
 
 Attachment (System::SharedPtr< System::IO::Stream > contentStream, System::String name)
 Initializes a new instance of the Attachment class. More...
 
 Attachment (System::SharedPtr< System::IO::Stream > contentStream, System::String name, System::String mediaType)
 Initializes a new instance of the Attachment class. More...
 
 Attachment (System::SharedPtr< System::IO::Stream > contentStream, System::SharedPtr< Aspose::Email::Mime::ContentType > contentType)
 Initializes a new instance of the Attachment class. More...
 
 Attachment ()
 
 Attachment (System::SharedPtr< System::IO::MemoryStream > content, System::SharedPtr< Aspose::Email::Mime::ContentType > contentType, System::String name, System::String contentLocation, System::String contentId)
 
 Attachment (System::SharedPtr< Aspose::Email::Mime::MimePart > part)
 Initializes a new instance of the Attachment class. More...
 
System::SharedPtr< AttachmentClone ()
 
System::SharedPtr< Calendar::Model::Property::AttachmentProperty > ToCalendarAttachmentProperty ()
 
System::SharedPtr< Mapi::MapiAttachmentConvertToMapiAttachment (Mapi::OutlookMessageFormat format, int32_t codePage, int32_t count, bool preserveDates) override
 
System::String CreateName (int32_t attachmentNumber)
 
- Public Member Functions inherited from Aspose::Email::AttachmentBase
System::SharedPtr< System::IO::Stream > get_ContentStream ()
 Gets the content stream. More...
 
void set_ContentStream (System::SharedPtr< System::IO::Stream > value)
 Sets the content stream. More...
 
System::String get_ContentId ()
 Gets the content id. More...
 
void set_ContentId (System::String value)
 Sets the content id. More...
 
virtual System::SharedPtr< Mime::HeaderCollectionget_Headers ()
 Gets headers collection of attachment. More...
 
System::SharedPtr< Aspose::Email::Mime::ContentTypeget_ContentType ()
 Gets the type of the content. More...
 
void set_ContentType (System::SharedPtr< Aspose::Email::Mime::ContentType > value)
 Sets the type of the content. More...
 
Aspose::Email::Mime::TransferEncoding get_TransferEncoding ()
 Gets the transfer encoding. More...
 
void set_TransferEncoding (Aspose::Email::Mime::TransferEncoding value)
 Sets the transfer encoding. More...
 
System::SharedPtr< System::Uri > get_ContentLocation () const
 Gets the content location. More...
 
void set_ContentLocation (System::SharedPtr< System::Uri > value)
 Sets the content location. More...
 
System::String get_ItemId () const
 
void set_ItemId (System::String value)
 
System::SharedPtr< Aspose::Email::Mime::MimePart > get_MimePart () const
 Gets the MIME part. More...
 
void set_MimePart (System::SharedPtr< Aspose::Email::Mime::MimePart > value)
 Sets the MIME part. More...
 
bool get_Hidden ()
 
void set_Hidden (bool value)
 
virtual void SaveInternal (System::SharedPtr< System::IO::Stream > stream)
 Saves the specified stream. More...
 
virtual void Save (System::SharedPtr< System::IO::Stream > stream)
 Saves the specified stream. More...
 
virtual void Save (System::String fileName)
 Saves the specified file name. More...
 
void SetContentFromString (System::String contentString, System::SharedPtr< Aspose::Email::Mime::ContentType > contentType)
 Sets the content from string. More...
 
void SetContentFromString (System::String contentString, System::SharedPtr< System::Text::Encoding > encoding, System::String mediaType)
 Sets the content from string. More...
 
void SetContentFromString (System::String contentString, System::SharedPtr< System::Text::Encoding > encoding, System::SharedPtr< Aspose::Email::Mime::ContentType > contentType, Aspose::Email::Mime::TransferEncoding te)
 Sets the content from string. More...
 
void SetSTnefContent (System::ArrayPtr< uint8_t > data)
 Sets the S/TNEF content. More...
 
virtual void PrepareForSending ()
 Prepares for sending. More...
 
void Dispose () override
 Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. More...
 

Static Public Member Functions

static System::SharedPtr< AttachmentCreateAttachmentFromString (System::String content, System::String name)
 Creates the attachment from string. More...
 
static System::SharedPtr< AttachmentCreateAttachmentFromString (System::String content, System::String name, System::SharedPtr< System::Text::Encoding > contentEncoding, System::String mediaType)
 Creates the attachment from string. More...
 
static System::SharedPtr< AttachmentCreateAttachmentFromString (System::String content, System::SharedPtr< Aspose::Email::Mime::ContentType > contentType)
 Creates the attachment from string. More...
 

Public Attributes

int32_t CollectionNum
 
- Public Attributes inherited from Aspose::Email::AttachmentBase
bool Disposed
 Is disposed. More...
 
int32_t TnefAttachIndex
 

Protected Member Functions

System::String GenerateContentId () override
 Generates the content id value. More...
 
virtual ~Attachment ()
 
- Protected Member Functions inherited from Aspose::Email::AttachmentBase
 AttachmentBase ()
 Initializes a new instance of the AttachmentBase class. More...
 
 AttachmentBase (System::SharedPtr< System::IO::Stream > contentStream, System::String name, System::String mediaType)
 Initializes a new instance of the AttachmentBase class. More...
 
 AttachmentBase (System::String fileName)
 Initializes a new instance of the AttachmentBase class. More...
 
 AttachmentBase (System::String fileName, System::String mediaType)
 Initializes a new instance of the AttachmentBase class. More...
 
 AttachmentBase (System::String fileName, System::SharedPtr< Aspose::Email::Mime::ContentType > contentType)
 Initializes a new instance of the AttachmentBase class. More...
 
 AttachmentBase (System::SharedPtr< System::IO::Stream > contentStream)
 Initializes a new instance of the AttachmentBase class. More...
 
 AttachmentBase (System::SharedPtr< System::IO::Stream > contentStream, System::String mediaType)
 Initializes a new instance of the AttachmentBase class. More...
 
 AttachmentBase (System::SharedPtr< System::IO::Stream > contentStream, System::SharedPtr< Aspose::Email::Mime::ContentType > contentType)
 Initializes a new instance of the AttachmentBase class. More...
 
virtual void Dispose (bool disposing)
 Releases unmanaged and - optionally - managed resources. More...
 
virtual ~AttachmentBase ()
 

Protected Attributes

bool isUri
 

Friends

class Aspose::Email::MailMessage
 
class Aspose::Email::AttachmentCollection
 
class Aspose::Email::Tools::CalendarConverter
 
class Aspose::Email::Clients::Exchange::WebService::ContactEwsConverter
 
class Aspose::Email::Tools::TaskConverter
 
class Aspose::Email::Clients::Exchange::WebService::Implementation::Contacts::Get::Helpers::LoadContactPhotosAndAttachmentsProcessor
 
class Aspose::Email::Clients::Exchange::WebService::Implementation::FetchAttachment::EwsClientAttachmentFetch
 
class Aspose::Email::Mapi::MapiTask
 
class Aspose::Email::Clients::Graph::V1::Model::TLAttachment
 
class Aspose::Email::Mapi::MailMessageInterpretor
 
class Aspose::Email::Mapi::MapiCalendarRecurrencePatternFactory
 
class Aspose::Email::Mapi::MapiMessage
 
class Aspose::Email::ReferenceAttachment
 
class Aspose::Email::Tools::ForwardMessageBuilder
 
class Aspose::Email::Tools::ResponseMessageBuilder
 

Additional Inherited Members

- Static Protected Member Functions inherited from Aspose::Email::AttachmentBase
static System::SharedPtr< System::Text::Encoding > GetEncodingFromContent (System::String contentString, System::SharedPtr< Aspose::Email::Mime::ContentType > contentType)
 Defines Encoding from content. More...
 

Detailed Description

Represents an e-mail attachment.

The following example shows how to add and remove an Attachment from MailMessage.

[C#]

// Create an instance of MailMessage class
var eml = new MailMessage {From = "sender@sender.com", To = "receiver@gmail.com"};
// Load an attachment
var attachment = new Attachment("1.txt");
eml.Attachments.Add(attachment);
// Remove attachment from your MailMessage
eml.Attachments.Remove(attachment);

[Visual Basic]

' Create an instance of MailMessage class
Dim eml = New MailMessage With {
.From = "sender@sender.com",
.[To] = "receiver@gmail.com"
}
' Load an attachment
Dim attachment = New Attachment("1.txt")
eml.Attachments.Add(attachment)
' Remove attachment from your MailMessage
eml.Attachments.Remove(attachment)

Constructor & Destructor Documentation

◆ Attachment() [1/9]

Aspose::Email::Attachment::Attachment ( System::String  fileName)

Initializes a new instance of the Attachment class.

/[ResourceExposure(ResourceScope.Machine)] /[ResourceConsumption(ResourceScope.Machine)]

Parameters
fileNameName of the file.

◆ Attachment() [2/9]

Aspose::Email::Attachment::Attachment ( System::String  fileName,
System::String  mediaType 
)

Initializes a new instance of the Attachment class.

/[ResourceExposure(ResourceScope.Machine)] /[ResourceConsumption(ResourceScope.Machine)]

Parameters
fileNameName of the file.
mediaTypeType media type name.

◆ Attachment() [3/9]

Aspose::Email::Attachment::Attachment ( System::String  fileName,
System::SharedPtr< Aspose::Email::Mime::ContentType contentType 
)

Initializes a new instance of the Attachment class.

/[ResourceExposure(ResourceScope.Machine)] /[ResourceConsumption(ResourceScope.Machine)]

Parameters
fileNameName of the file.
contentTypeThe ContentType.

◆ Attachment() [4/9]

Aspose::Email::Attachment::Attachment ( System::SharedPtr< System::IO::Stream >  contentStream,
System::String  name 
)

Initializes a new instance of the Attachment class.

Parameters
contentStreamThe content stream of attachment.
nameThe attachment name.

◆ Attachment() [5/9]

Aspose::Email::Attachment::Attachment ( System::SharedPtr< System::IO::Stream >  contentStream,
System::String  name,
System::String  mediaType 
)

Initializes a new instance of the Attachment class.

Parameters
contentStreamThe content stream of attachment.
nameThe attachment name.
mediaTypeThe media type name.

◆ Attachment() [6/9]

Aspose::Email::Attachment::Attachment ( System::SharedPtr< System::IO::Stream >  contentStream,
System::SharedPtr< Aspose::Email::Mime::ContentType contentType 
)

Initializes a new instance of the Attachment class.

Parameters
contentStreamThe content stream of attachment.
contentTypeThe ContentType.

◆ Attachment() [7/9]

Aspose::Email::Attachment::Attachment ( )

◆ Attachment() [8/9]

Aspose::Email::Attachment::Attachment ( System::SharedPtr< System::IO::MemoryStream >  content,
System::SharedPtr< Aspose::Email::Mime::ContentType contentType,
System::String  name,
System::String  contentLocation,
System::String  contentId 
)

◆ Attachment() [9/9]

Aspose::Email::Attachment::Attachment ( System::SharedPtr< Aspose::Email::Mime::MimePart >  part)

Initializes a new instance of the Attachment class.

Parameters
partAn attachment mime part
Exceptions
ArgumentNullExceptionpart is null

◆ ~Attachment()

virtual Aspose::Email::Attachment::~Attachment ( )
protectedvirtual

Member Function Documentation

◆ Clone()

System::SharedPtr<Attachment> Aspose::Email::Attachment::Clone ( )

◆ ConvertToMapiAttachment()

System::SharedPtr<Mapi::MapiAttachment> Aspose::Email::Attachment::ConvertToMapiAttachment ( Mapi::OutlookMessageFormat  format,
int32_t  codePage,
int32_t  count,
bool  preserveDates 
)
overridevirtual

◆ CreateAttachmentFromString() [1/3]

static System::SharedPtr<Attachment> Aspose::Email::Attachment::CreateAttachmentFromString ( System::String  content,
System::SharedPtr< Aspose::Email::Mime::ContentType contentType 
)
static

Creates the attachment from string.

Parameters
contentA string that represents the content of attachment.
contentTypeThe ContentType.
Returns
Returns created attachment

◆ CreateAttachmentFromString() [2/3]

static System::SharedPtr<Attachment> Aspose::Email::Attachment::CreateAttachmentFromString ( System::String  content,
System::String  name 
)
static

Creates the attachment from string.

Parameters
contentA string that represents the content of attachment.
nameThe attachment name.
Returns
Returns created attachment

◆ CreateAttachmentFromString() [3/3]

static System::SharedPtr<Attachment> Aspose::Email::Attachment::CreateAttachmentFromString ( System::String  content,
System::String  name,
System::SharedPtr< System::Text::Encoding >  contentEncoding,
System::String  mediaType 
)
static

Creates the attachment from string.

Parameters
contentA string that represents the content of attachment.
nameThe attachment name.
contentEncodingThe content encoding.
mediaTypeThe media type name
Returns
Returns created attachment

◆ CreateName()

System::String Aspose::Email::Attachment::CreateName ( int32_t  attachmentNumber)

◆ GenerateContentId()

System::String Aspose::Email::Attachment::GenerateContentId ( )
overrideprotectedvirtual

Generates the content id value.

Returns

Reimplemented from Aspose::Email::AttachmentBase.

◆ get_ContentDisposition()

System::SharedPtr<Aspose::Email::Mime::ContentDisposition> Aspose::Email::Attachment::get_ContentDisposition ( )

Gets Content-Disposition header

◆ get_CreatedName()

System::String Aspose::Email::Attachment::get_CreatedName ( ) const

Created name from subject in case when attacment is message/rfc822

◆ get_Id()

System::SharedPtr<ObjectIdentifier> Aspose::Email::Attachment::get_Id ( ) const

Object identifier

◆ get_IsEmbeddedMessage()

bool Aspose::Email::Attachment::get_IsEmbeddedMessage ( )

Gets a value indicating whether the attachment is an embedded message.

◆ get_IsTnef()

bool Aspose::Email::Attachment::get_IsTnef ( )

Gets a value indicating whether the attachment is TNEF formatted message.

◆ get_IsUri()

bool Aspose::Email::Attachment::get_IsUri ( ) const

Gets a value indicating whether attachment is URI-attachment.

◆ get_Name()

System::String Aspose::Email::Attachment::get_Name ( )

Gets an attachment name

◆ get_NameEncoding()

System::SharedPtr<System::Text::Encoding> Aspose::Email::Attachment::get_NameEncoding ( )

Gets an encoding of attachment name

◆ get_PreferredTextEncoding()

System::SharedPtr<System::Text::Encoding> Aspose::Email::Attachment::get_PreferredTextEncoding ( )
overridevirtual

Gets a preferred text encoding

Implements Aspose::Email::IPreferredTextEncodingProvider.

◆ set_CreatedName()

void Aspose::Email::Attachment::set_CreatedName ( System::String  value)

Created name from subject in case when attacment is message/rfc822

◆ set_Name()

void Aspose::Email::Attachment::set_Name ( System::String  value)

Sets an attachment name

◆ set_NameEncoding()

void Aspose::Email::Attachment::set_NameEncoding ( System::SharedPtr< System::Text::Encoding >  value)

Sets an encoding of attachment name

◆ set_PreferredTextEncoding()

void Aspose::Email::Attachment::set_PreferredTextEncoding ( System::SharedPtr< System::Text::Encoding >  value)
overridevirtual

Sets a preferred text encoding

Implements Aspose::Email::IPreferredTextEncodingProvider.

◆ ToCalendarAttachmentProperty()

System::SharedPtr<Calendar::Model::Property::AttachmentProperty> Aspose::Email::Attachment::ToCalendarAttachmentProperty ( )

Friends And Related Function Documentation

◆ Aspose::Email::AttachmentCollection

◆ Aspose::Email::Clients::Exchange::WebService::ContactEwsConverter

friend class Aspose::Email::Clients::Exchange::WebService::ContactEwsConverter
friend

◆ Aspose::Email::Clients::Exchange::WebService::Implementation::Contacts::Get::Helpers::LoadContactPhotosAndAttachmentsProcessor

friend class Aspose::Email::Clients::Exchange::WebService::Implementation::Contacts::Get::Helpers::LoadContactPhotosAndAttachmentsProcessor
friend

◆ Aspose::Email::Clients::Exchange::WebService::Implementation::FetchAttachment::EwsClientAttachmentFetch

friend class Aspose::Email::Clients::Exchange::WebService::Implementation::FetchAttachment::EwsClientAttachmentFetch
friend

◆ Aspose::Email::Clients::Graph::V1::Model::TLAttachment

friend class Aspose::Email::Clients::Graph::V1::Model::TLAttachment
friend

◆ Aspose::Email::MailMessage

friend class Aspose::Email::MailMessage
friend

◆ Aspose::Email::Mapi::MailMessageInterpretor

friend class Aspose::Email::Mapi::MailMessageInterpretor
friend

◆ Aspose::Email::Mapi::MapiCalendarRecurrencePatternFactory

◆ Aspose::Email::Mapi::MapiMessage

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

◆ Aspose::Email::Mapi::MapiTask

friend class Aspose::Email::Mapi::MapiTask
friend

◆ Aspose::Email::ReferenceAttachment

◆ Aspose::Email::Tools::CalendarConverter

friend class Aspose::Email::Tools::CalendarConverter
friend

◆ Aspose::Email::Tools::ForwardMessageBuilder

◆ Aspose::Email::Tools::ResponseMessageBuilder

◆ Aspose::Email::Tools::TaskConverter

friend class Aspose::Email::Tools::TaskConverter
friend

Member Data Documentation

◆ CollectionNum

int32_t Aspose::Email::Attachment::CollectionNum

◆ isUri

bool Aspose::Email::Attachment::isUri
protected
Attachment()
@ Arrival
By internal date and time of the message. This differs from the ON criteria in SEARCH,...