---
title: "Read Body Resources and Attachments"
canonical_url: "https://www.compdf.com/guides/generation-sdk/dotnet-core/generation/email-resources-and-attachments"
md_url: "https://www.compdf.com/guides/generation-sdk/dotnet-core/generation/email-resources-and-attachments.md"
description: "ComPDF SDK Guides. In this developer's guide, all the details and how to use ComPDF for SDK Guides will be covered in depth."
---

# Read Body Resources and Attachments

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:

```csharp
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 |
