High priority emails

There are several different email headers that make email high priority.

Most correct is Priority header, but also Importance is used.
Outlook uses X-Priority header.

Mail.dll email library offers simple solution of this problem: PriorityHigh() method.

The following code sends high priority email, that has all mentioned above headers set accordingly:

// C# version:
MailBuilder builder = new MailBuilder();
builder.Subject = "This is important";
builder.Html = "<html>....</html>";
builder.From.Add(new MailBox("alice@mail.com", "Alice"));
builder.To.Add(new MailBox("bob@mail.com", "Bob"));


IMail email = builder.Create();

using (Smtp client = new Smtp())
    client.UseBestLogin("alice@example.org", "password");

and as usual VB.NET code:

' VB.NET version:

Dim builder As MailBuilder = New MailBuilder()
builder.Subject = "This is important"
builder.Html = "<html>....</html>"
builder.From.Add(New MailBox("alice@mail.com", "Alice"))
builder.[To].Add(New MailBox("bob@mail.com", "Bob"))


Dim email As IMail = builder.Create()

Using client As Smtp = New Smtp()
    client.UseBestLogin("alice@example.org", "password")
End Using

Using fluent interface:

// C# version:

using Fluent = Limilabs.Mail.Fluent;

    .Subject("This is important")
    .WithCredentials("user", "password")
' VB.NET version:

Imports Fluent = Limilabs.Mail.Fluent;

Fluent.Mail.Html("<html>....</html>") _
    .Subject("This is important") _
    .To("to@example.com") _
    .From("from@example.com") _
    .PriorityHigh() _
    .UsingNewSmtp() _
    .Server("smtp.example.com") _
    .WithCredentials("user", "password") _
    .WithSSL() _

PriorityLow() method is also available.

It’s also really easy to check the email’s priority with GetGenericPriority.
GetGenericPriority checks Priority, Importance and X-Priority headers.

// C# version:

IMail email = new MailBuilder()

GenericPriority priority = email.GetGenericPriority();
if (priority == GenericPriority.High)
    // Your code goes here

' VB.NET version:

Dim email As IMail = New MailBuilder() _

Dim priority As GenericPriority = email.GetGenericPriority()

If priority = GenericPriority.High Then
    ' Your code goes here
End If

Tags: , , ,


Consider using our Q&A forum for asking any questions.