MailBee.NET Objects 4.0

MailMessage.ContentType Property

Gets the content type of the message.

public string ContentType {get;}

Property Value

A string containing the content type of the mail message. The default value for a new message is text/plain.

Remarks

The value of this property is taken from the Content-Type header. The typical content types are:

If the content-type is missing in the message being parsed, this property will return an empty string.

You do not need to manually set the content-type of the message. It will be set automatically depending on the structure of the message (e.g. its text bodies and attachments).

Example

This sample downloads the first message from the specified POP3 account and displays the content type of the message.

[C#]
using System;
using MailBee;
using MailBee.Pop3Mail;
using MailBee.Mime;

class Sample
{
    static void Main(string[] args)
    {
        // Quickly download the first message from the specified POP3 account
        MailMessage msg = Pop3.QuickDownloadMessage("pop3.mail.com", "dan_brown", "password", 1);

        // Show the content type of the message.
        Console.WriteLine("Content type is " + msg.ContentType);
    }
}
[Visual Basic]
Imports System
Imports MailBee
Imports MailBee.Pop3Mail
Imports MailBee.Mime

Module Sample
    Sub Main(ByVal args As String())
        ' Quickly download the first message from the specified POP3 account
        Dim msg As MailMessage = Pop3.QuickDownloadMessage("pop3.mail.com", "dan_brown", "password", 1)

        ' Show the content type of the message.
        Console.WriteLine("Content type is " & msg.ContentType)
    End Sub
End Module

See Also

MailMessage Class | MailBee.Mime Namespace