<<Back To Faq 3.3.1


Complete FAQ Listing


3.3.1 How do I change the email priority? Printer Friendly

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

PropertyDescription
HighThe email has high priority. 
LowThe email has low priority. 
NormalThe 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



 



The formatted version of this faq can be found at http://www.SystemNetMail.com/faq/3.3.1.aspx