PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
The PDF only lists the attachments and does not contain their content. You can read the attachment bytes from the conversion result and handle them in your application. Here is an example:
using (CEmailResult result = CEmailConverter.ConvertToHtml("/mail.eml"))
{
// Source of the selected primary body
CEmailBodySource body = result.GetSelectedBodySource();
Console.WriteLine($"Body: {body.MediaType} ({body.Origin})");
// Body resources, such as images
foreach (CEmailResource resource in result.GetResources())
{
Console.WriteLine($"Resource: {resource.RelativePath}, {resource.MediaType}, {resource.Data.Length} bytes");
}
// Attachments
foreach (CEmailAttachment attachment in result.GetAttachments())
{
// When the attachment data is corrupted, only its name and type are kept and HasData is false
if (attachment.HasData)
{
File.WriteAllBytes(Path.Combine("/attachments/", Path.GetFileName(attachment.DisplayName)), attachment.Data);
}
}
}Main properties of CEmailAttachment:
| Property | Description |
|---|---|
OriginalName | Original file name in the email |
DisplayName | Sanitized file name for display |
MediaType | MIME type |
HasData / Data | Whether there is data / the attachment bytes. Data is null when HasData is false |
Hidden | Whether the attachment is hidden, for example an inline resource referenced by the body |
ReferencedByBody | Whether the attachment is referenced by the body |
NestedMessage | Whether the attachment is an embedded message |