Class Attachment
Represents email attachment.
public record Attachment : IEquatable<Attachment>
- Inheritance
-
Attachment
- Implements
Constructors
Attachment(string, string, DispositionType?, string?, string?)
Default instance constructor.
public Attachment(string content, string fileName, DispositionType? disposition = null, string? mimeType = null, string? contentId = null)
Parameters
content
stringThe Base64 encoded content of the attachment.
Required. Must be non-empty string.
fileName
stringAttachment file name.
Required. Must be non-empty string.
disposition
DispositionTypeThe attachment's content disposition, specifying how you would like the attachment to be displayed.
Optional. Defaults to Attachment if not specified explicitly.
mimeType
stringAttachment MIME type identifier (e.g. "text/plain", "application/pdf", etc.)
Optional.
contentId
stringThe attachment's content ID.
Optional.
Exceptions
- ArgumentNullException
When
content
is null or Empty.
WhenfileName
is null or Empty.
Properties
Content
Gets the Base64 encoded content of the attachment.
Required. Must be non-empty string.
[JsonPropertyName("content")]
[JsonPropertyOrder(1)]
public string Content { get; }
Property Value
- string
Contains Base64 encoded content of the attachment.
ContentId
Gets the attachment's content ID.
Optional.
[JsonPropertyName("content_id")]
[JsonPropertyOrder(5)]
public string? ContentId { get; }
Property Value
- string
Contains the attachment's content ID.
Remarks
This is used when the disposition is set to Inline and the attachment is an image, allowing the file to be displayed within the body of your email.
Disposition
Gets the attachment's content disposition, specifying how the attachment will be displayed.
Optional.
[JsonPropertyName("disposition")]
[JsonPropertyOrder(3)]
public DispositionType Disposition { get; }
Property Value
- DispositionType
Indicates attachment's content disposition.
Inline results in the attached file are displayed automatically within the message.
Attachment results in the attached file require some action to be taken before it is displayed, such as opening or downloading the file.Defaults to Attachment, if not specified explicitly.
FileName
Gets attachment's file name.
Required. Must be non-empty string.
[JsonPropertyName("filename")]
[JsonPropertyOrder(2)]
public string FileName { get; }
Property Value
- string
Contains attachment file name.
MimeType
Gets the attachment's MIME type identifier.
Optional.
[JsonPropertyName("type")]
[JsonPropertyOrder(4)]
public string? MimeType { get; }
Property Value
- string
Contains the attachment's MIME type identifier.
E.g. "text/plain", "application/pdf", etc.