MailBee.NET Objects 4.0

Attachment.ContentType Property

Gets the content type of the attachment.

public string ContentType {get;}

Property Value

A string containing the attachment's content type taken from Content-Type header, or an empty string if the content type is not set.

Remarks

Some examples of attachment content types:

When adding an attachment to the e-mail message (for instance, using Add method of AttachmentCollection) and the content type is not specified, MailBee automatically determines its content type according to the file extension.

Example

This sample loads the message from .EML file and displays the content type of each attachment.

[C#]
// To use the code below, import MailBee namespaces at the top of your code.
using MailBee;
using MailBee.Mime;

// The actual code (put it into a method of your class)

// Load the message from file.
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\TestMail.eml");

// For every attachment...
foreach (Attachment attach in msg.Attachments)             
{
    // ...show attachment type.
    Console.WriteLine("The type is " + attach.ContentType);
}
[Visual Basic]
' To use the code below, import MailBee namespaces at the top of your code.
Imports MailBee
Imports MailBee.Mime

' The actual code (put it into a method of your class)

' Load the message from file.
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\TestMail.eml")

' For every attachment...
For Each attach As Attachment In msg.Attachments
    ' ...show attachment type.
    Console.WriteLine("The type is " & attach.ContentType)
Next

See Also

Attachment Class | MailBee.Mime Namespace | Headers