Repository navigation
v1.0.0
UPGRADE WARNING
Upgrading to this version from version 0.0.X to 1.0.0+ will cause existing code to break. Please see the full usage examples for more details.
Major changes
- Removed
public static Attachment FromFile(string filePath, string mimeType, Disposition disposition = Disposition.Attachment, bool validateMimeType = true) - Replace with
public static Attachment FromBase64(string base64Content, string filename, string? mimeType = null, Disposition disposition = Disposition.Attachment, string? contentId = null) - Removed
public static Attachment FromFile(string filePath, string mimeType, Disposition disposition = Disposition.Attachment, bool validateMimeType = true) - Replaced with
public static Attachment FromFile(string filePath, Disposition disposition = Disposition.Attachment, string? contentId = null, string? filename = null, string? mimeType = null)
When creating attachments, the library automatically attempts to determine the MIME type. This detection is based on:
- The
filenameargument when usingAttachment.FromFileorAttachment.FromBase64. - The
filePathwhen usingAttachment.from_file.
If the MIME type cannot be determined, an exception will be raised. Mime types can be manually overridden as demonstrated in the section below.
Attachment MIME Type Deduction Behavior
- When creating attachments, the library automatically determines the MIME type based on the file extension.
- If the MIME type cannot be determined, an exception is raised.
// Create an attachment from disk; the MIME type will be "text/csv", and disposition will be "Disposition.Attachment"
Attachment.FromFile("C:/temp/file.csv");
// This will throw an error, as the MIME type is unknown
Attachment.FromFile("C:/temp/file.unknown");
// Create an attachment and specify the type information. The disposition will be "Disposition.Attachment", filename will be unknown.txt, and MIME type "text/plain"
Attachment.FromFile("C:/temp/file.unknown", filename: "unknown.txt");
// Create an attachment and specify the type information. The disposition will be "Disposition.Attachment", filename will be file.unknown, and MIME type "text/plain"
Attachment.FromFile("C:/temp/file.unknown", mimeType: "text/plain");New Features
Ability to set the HeaderFrom to be different from the sender address.
var message = new Message("This is a test email", new MailUser("sender@example.com", "Joe Sender"), new MailUser("noreply@example.com", "Some Business System"));Inline Attachments and Content-IDs
When creating attachments, they are Disposition.Attachment by default. To properly reference a Content-ID (e.g.,
<img src="cid:logo">), you must explicitly set the attachment disposition to Disposition.Inline.
If the attachment type is set to Disposition.Inline, a default unique Content-ID will be generated.
Using a Dynamically Generated Content-ID
var logo = Attachment.FromFile("C:/temp/logo.png", Disposition.Inline);
message.AddContent(new Content($"<b>Test</b><br><img src=\"cid:{logo.ContentId}\">", ContentType.Html));
message.AddAttachment(logo);Setting a Custom Content-ID
message.AddAttachment(Attachment.FromFile("C:/temp/logo.png", Disposition.Inline, "logo"));
message.AddContent(new Content("<b>Test</b><br><img src=\"cid:logo\">", ContentType.Html));Known Issues
There is a known issue where empty file content results in a 400 Bad Request error.
{
"content": "",
"disposition": "attachment",
"filename": "empty.txt",
"id": "1ed38149-70b2-4476-84a1-83e73913d43c",
"type": "text/plain"
}🔹 API Response:
Status Code: 400/BadRequest
Reason: attachments[0].content is required
Message ID:
Request ID: fe9a1acf60a20c9d90bed843f6530156
Raw JSON: {"request_id":"fe9a1acf60a20c9d90bed843f6530156","reason":"attachments[0].content is required"}
This issue has been reported to Proofpoint Product Management.
Limitations
- The Proofpoint API currently does not support empty file attachments.
- If an empty file is sent, you will receive a 400 Bad Request error.
Additional Resources
For more information, refer to the official Proofpoint Secure Email Relay API documentation:
API Documentation
Full Changelog: v0.0.5...v1.0.0