Although the priority of a message is controlled by headers, in the
System.Net.Mail namespace, the Priority of a message is actually exposed as a
property of the MailMessage object.
A priority can have the following values
| Property | Description |
|---|
| High | The email has high priority. |
| Low | The email has low priority. |
| Normal | The email has normal priority. |
The following example demonstrates setting the MailMessage object to a High
priority.
[ C# ]
static void SetPriority()
{
//create the mail message
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress("me@mycompany.com");
mail.To.Add("you@yourcompany.com");
//set the content
mail.Subject = "This is an email";
mail.Body = "this is the body content of the email.";
//specify the priority of the mail message
mail.Priority = MailPriority.High;
//send the message
SmtpClient smtp = new SmtpClient("127.0.0.1");
smtp.Send(mail);
}
[ VB.NET ]
Sub SetPriority()
'create the mail message
Dim mail As New MailMessage()
'set the addresses
mail.From = New MailAddress("me@mycompany.com")
mail.To.Add("you@yourcompany.com")
'set the content
mail.Subject = "This is an email"
mail.Body = "this is the body content of the email."
'specify the priority of the mail message
mail.Priority = MailPriority.High
'send the message
Dim smtp As New SmtpClient("127.0.0.1")
smtp.Send(mail)
End Sub 'SetPriority