Attachment

Inheritance: java.lang.Object, com.aspose.email.AttachmentBase

All Implemented Interfaces: com.aspose.email.IPreferredTextEncodingProvider, com.aspose.email.IAttachment

public class Attachment extends AttachmentBase implements IPreferredTextEncodingProvider, IAttachment

Represents an e-mail attachment.

Constructors

Constructor Description
Attachment(String fileName) Initializes a new instance of the Attachment class.
Attachment(String fileName, String mediaType) Initializes a new instance of the Attachment class.
Attachment(String fileName, ContentType contentType) Initializes a new instance of the Attachment class.
Attachment(InputStream contentStream, String name) Initializes a new instance of the Attachment class.
Attachment(InputStream contentStream, String name, String mediaType) Initializes a new instance of the Attachment class.
Attachment(InputStream contentStream, ContentType contentType) Initializes a new instance of the Attachment class.

Methods

Method Description
isEmbeddedMessage() Gets a value indicating whether the attachment is an embedded message.
getName() Gets or sets an attachment name
setName(String value) Gets or sets an attachment name
getNameEncoding() Gets or sets an encoding of attachment name
setNameEncoding(Charset value) Gets or sets an encoding of attachment name
getContentDisposition() Gets Content-Disposition header
isUri() Gets a value indicating whether attachment is URI-attachment.
getPreferredTextEncoding() Gets or sets a preferred text encoding
setPreferredTextEncoding(Charset value) Gets or sets a preferred text encoding
createAttachmentFromString(String content, String name) Creates the attachment from string.
createAttachmentFromString(String content, String name, Charset contentEncoding, String mediaType) Creates the attachment from string.
createAttachmentFromString(String content, ContentType contentType) Creates the attachment from string.

Attachment(String fileName)

public Attachment(String fileName)

Initializes a new instance of the Attachment class.

Parameters:

Parameter Type Description
fileName java.lang.String Name of the file.

Attachment(String fileName, String mediaType)

public Attachment(String fileName, String mediaType)

Initializes a new instance of the Attachment class.

Parameters:

Parameter Type Description
fileName java.lang.String Name of the file.
mediaType java.lang.String Type media type name.

Attachment(String fileName, ContentType contentType)

public Attachment(String fileName, ContentType contentType)

Initializes a new instance of the Attachment class.

Parameters:

Parameter Type Description
fileName java.lang.String Name of the file.
contentType ContentType The ``` ContentType ```(AttachmentBase#getContentType/AttachmentBase#setContentType(ContentType)).

Attachment(InputStream contentStream, String name)

public Attachment(InputStream contentStream, String name)

Initializes a new instance of the Attachment class.

Parameters:

Parameter Type Description
contentStream java.io.InputStream The content stream of attachment.
name java.lang.String The attachment name.

Attachment(InputStream contentStream, String name, String mediaType)

public Attachment(InputStream contentStream, String name, String mediaType)

Initializes a new instance of the Attachment class.

Parameters:

Parameter Type Description
contentStream java.io.InputStream The content stream of attachment.
name java.lang.String The attachment name.
mediaType java.lang.String The media type name.

Attachment(InputStream contentStream, ContentType contentType)

public Attachment(InputStream contentStream, ContentType contentType)

Initializes a new instance of the Attachment class.

Parameters:

Parameter Type Description
contentStream java.io.InputStream The content stream of attachment.
contentType ContentType The ``` ContentType ```(AttachmentBase#getContentType/AttachmentBase#setContentType(ContentType)).

isEmbeddedMessage()

public final boolean isEmbeddedMessage()

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

Returns: boolean

getName()

public final String getName()

Gets or sets an attachment name

Returns: java.lang.String

setName(String value)

public final void setName(String value)

Gets or sets an attachment name

Parameters:

Parameter Type Description
value java.lang.String

getNameEncoding()

public final Charset getNameEncoding()

Gets or sets an encoding of attachment name

Returns: java.nio.charset.Charset

setNameEncoding(Charset value)

public final void setNameEncoding(Charset value)

Gets or sets an encoding of attachment name

Parameters:

Parameter Type Description
value java.nio.charset.Charset

getContentDisposition()

public final ContentDisposition getContentDisposition()

Gets Content-Disposition header

Returns: ContentDisposition

isUri()

public final boolean isUri()

Gets a value indicating whether attachment is URI-attachment.

Returns: boolean

getPreferredTextEncoding()

public final Charset getPreferredTextEncoding()

Gets or sets a preferred text encoding

Returns: java.nio.charset.Charset

setPreferredTextEncoding(Charset value)

public final void setPreferredTextEncoding(Charset value)

Gets or sets a preferred text encoding

Parameters:

Parameter Type Description
value java.nio.charset.Charset

createAttachmentFromString(String content, String name)

public static Attachment createAttachmentFromString(String content, String name)

Creates the attachment from string.

Parameters:

Parameter Type Description
content java.lang.String A string that represents the content of attachment.
name java.lang.String The attachment name.

Returns: Attachment - Returns created attachment

createAttachmentFromString(String content, String name, Charset contentEncoding, String mediaType)

public static Attachment createAttachmentFromString(String content, String name, Charset contentEncoding, String mediaType)

Creates the attachment from string.

Parameters:

Parameter Type Description
content java.lang.String A string that represents the content of attachment.
name java.lang.String The attachment name.
contentEncoding java.nio.charset.Charset The content encoding.
mediaType java.lang.String The media type name

Returns: Attachment - Returns created attachment

createAttachmentFromString(String content, ContentType contentType)

public static Attachment createAttachmentFromString(String content, ContentType contentType)

Creates the attachment from string.

Parameters:

Parameter Type Description
content java.lang.String A string that represents the content of attachment.
contentType ContentType The ``` ContentType ```(AttachmentBase#getContentType/AttachmentBase#setContentType(ContentType)).

Returns: Attachment - Returns created attachment