Constructor Attachment
Attachment(string)
Initializes a new instance of the Attachment class by loading the content from the specified file path. The file must be one of the supported formats:
- PNG
- BMP
- GIF
- PSD
- PIC
- JPEG
- PNM
- HDR
- TGA
- WEBP
- TIFF
- HTML
- TXT
- DOCX
- XLSX
- PPTX
public Attachment(string path)
Parameters
path
stringThe file system path to the attachment file.
Exceptions
- FileNotFoundException
Thrown when the specified file does not exist.
- UnsupportedFileTypeException
Thrown when the file format is not supported (see above for supported formats).
Attachment(byte[], string)
Initializes a new instance of the Attachment class with the provided data and name. The data must represent one of the supported formats:
- PNG
- BMP
- GIF
- PSD
- PIC
- JPEG
- PNM
- HDR
- TGA
- WEBP
- TIFF
- HTML
- TXT
- DOCX
- XLSX
- PPTX
public Attachment(byte[] data, string name)
Parameters
data
byte[]The byte array representing the content of the attachment.
name
stringThe name of the attachment file.
Exceptions
- ArgumentNullException
Thrown when
data
orname
isnull
.- UnsupportedFileTypeException
Thrown when the file format is not supported (see above for supported formats).
Attachment(Stream, string)
Initializes a new instance of the Attachment class by reading the content from the provided stream and using the given file name. The stream must contain data representing one of the supported formats:
- PNG
- BMP
- GIF
- PSD
- PIC
- JPEG
- PNM
- HDR
- TGA
- WEBP
- TIFF
- HTML
- TXT
- DOCX
- XLSX
- PPTX
public Attachment(Stream data, string name)
Parameters
data
StreamA readable Stream containing the attachment data. The stream is fully read; it is not disposed by the constructor.
name
stringThe logical file name associated with this attachment.
Exceptions
- ArgumentNullException
Thrown when
data
orname
isnull
.- ArgumentException
Thrown when
data
is not readable.- UnsupportedFileTypeException
Thrown if the stream data is not one of the supported formats.
Attachment(ImageBuffer, bool, string)
Initializes a new Attachment from an in-memory image buffer.
public Attachment(ImageBuffer image, bool ownsImage = true, string name = "image")
Parameters
image
ImageBufferThe image buffer containing pixel data. Cannot be
null
.ownsImage
boolWhether this instance takes ownership of
image
and will dispose it when disposed. Default:true
.name
stringThe logical name for this attachment. Default:
"image"
.
Exceptions
- ArgumentNullException
Thrown if
image
isnull
.