Class EmailAttachment
An attachment (or inline image) attached to an email message.
public sealed class EmailAttachment
- Inheritance
-
EmailAttachment
- Inherited Members
Constructors
EmailAttachment(string, byte[], string?, bool, string?)
Creates an attachment from a byte array.
public EmailAttachment(string fileName, byte[] content, string? mediaType = null, bool isInline = false, string? contentId = null)
Parameters
EmailAttachment(string, Stream, string?, bool, string?)
Creates an attachment by reading all bytes from a stream.
public EmailAttachment(string fileName, Stream content, string? mediaType = null, bool isInline = false, string? contentId = null)
Parameters
Properties
Content
The attachment content bytes.
public byte[] Content { get; }
Property Value
- byte[]
ContentId
The content id used to reference inline images (cid:value) from the HTML body.
public string? ContentId { get; }
Property Value
FileName
The file name of the attachment.
public string FileName { get; }
Property Value
IsInline
True when the attachment is an inline image referenced via a content id (cid:).
public bool IsInline { get; }
Property Value
MediaType
The MIME media type (for example, "application/pdf").
public string MediaType { get; }
Property Value
Methods
FromFile(string, string?, bool, string?)
Creates an attachment from a file on disk.
public static EmailAttachment FromFile(string path, string? mediaType = null, bool isInline = false, string? contentId = null)
Parameters
Returns
GuessMediaType(string)
Infers a MIME media type from a file name extension.
public static string GuessMediaType(string fileName)
Parameters
fileNamestring