Attachment Class
Represents a mail message attachment.
- Inheritance:
- System.
Object Attachment
Constructors
Attachment(MediaType, Byte[])
Initializes a new instance of the Attachment class with specified content type and content.
Parameters
contentType
- Media
Type
The Content-Type header value.
content
- System.
Byte []
The content.
Exceptions
- System.
Argument Null Exception
Content is null.
Attachment(MediaType, Stream)
Initializes a new instance of the Attachment class with specified content type and content.
Parameters
contentType
- Media
Type
The Content-Type header value.
content
- System.
IO. Stream
The content.
Exceptions
- System.
Argument Exception
Content is null or empty.
Attachment(MediaType, Stream, String)
Initializes a new instance of the Attachment class with specified content type, content and file name.
Parameters
contentType
- Media
Type
The Content-Type header value.
content
- System.
IO. Stream
The content.
fileName
- System.
String
File name.
Exceptions
- System.
Argument Exception
Content is null or empty.
Attachment(Stream, String)
Initializes a new instance of the Attachment class with specified content and file name.
Parameters
content
- System.
IO. Stream
The content.
fileName
- System.
String
File name.
Exceptions
- System.
Argument Exception
Content is null or empty.
Attachment(String)
Initializes a new instance of the Attachment class from specified file.
Parameters
filePath
- System.
String
A relative or absolute path for the file.
Exceptions
- System.
Argument Exception
File path is null or empty.
Properties
ContentId
Gets or sets the attachment content id.
Property Value
- System.
String
The attachment content id.
Data
Gets the attachment data stream.
Property Value
- System.
IO. Memory Stream
The attachment data stream.
DispositionType
Gets the attachment content disposition type.
Property Value
The attachment content disposition type.
Exceptions
- System.
Argument Exception
Content disposition type cannot be set to Unknown.
FileName
Gets the file name.
Property Value
- System.
String
The file name, if defined; otherwise, null.
MimeEntity
Gets the underlying MIME entity.
Property Value
The underlying MIME entity.
Size
Gets the data size.
Property Value
- System.
Nullable <System.Int32 >
The data size, if defined; otherwise, null.
Methods
GetTaggedProperty(PropertyTag)
Returns the value stored into a specific tagged property. Works only for messages loaded from MSG files.
Parameters
tag
- Property
Tag
The ID of the tag from which to retrieve the value.
Returns
- System.
Object
An System.
Save(Stream)
Saves the attachment into the specified stream.
Parameters
stream
- System.
IO. Stream
The stream in which to save the attachment.
Save(String)
Saves the attachment into the specified path.
Parameters
path
- System.
String
The path to which to save the attachment.
SetTaggedProperty(PropertyTag, Object)
Explicitly sets the value of a tagged property. Works only for messages that will be saved to a MSG file. Items set with this method will be written when saving the message to .msg, overwriting any other properties normally set by other members, which can cause errors.
For example, setting Gem
Parameters
tag
- Property
Tag
The ID of the tag to set.
value
- System.
Object
The value of the tagged property.