Part of the application I'm working on for my client involves sending emails for events. Sometimes these are highly important. My client, and most of my client's clients, use Outlook, which has the ability to mark a mail message as High Importance.
Now, I know it is callous to assume that all end users will be using the same interface, sp I am not. But considering you can send email from Outlook as High Importance even if the target is not necessarily reading through Outlook, that means that there is basically some data stored, somehow, that lets Outlook know if a particular message was assigned as High Importance. That's my interpretation, at least.
The application currently uses System.Net.Mail
to send out emails, using System.Net.Mail.MailMessages
for writing them and System.Net.Mail.SmtpClient
to send them. Is it possible to set this "High Importance" setting with System.Net.Mail
's abilities? If not, is there any assembly available which can configure this setting?
Set the Priority property of the mail message. Its values are Normal, Low or High.
Very late edit: As @StefanSteiger notes, Priority is only guaranteed to work for Outlook. In the intervening 8 years since this question/answer were posted, the industry has settled on the Importance header as the preferred way to do this.
Even later edit: The source for MailMessage makes it clear that setting the Priority actually sets three things: the XPriority header, the Priority header, and the Importance header. So using the Priority property will behave as expected in any mail client, and will set the appropriate headers.
You can set the System.Net.Mail.MailPriority setting.
MailPriority.High
for example.
Use this - it works for me.
Dim mail As New MailMessage()
mail = New MailMessage()
mail.Priority = MailPriority.High
mail.Priority = MailPriority.Normal
mail.Priority = MailPriority.Low
Just because Outlook treats priority as importance,
that doesn't mean all other email programs do so as well.
Priority and importance are NOT the same thing.
The correct answer is:
mail.Headers.Add("Importance", "High"); // High, normal, or low
values are case insensitive.
https://www.iana.org/assignments/message-headers/message-headers.xhtml
https://tools.ietf.org/html/rfc4021#page-32
Jumping in late here! Priority and Importance are not the same, but both are available to most developers to set. How do you choose? Well, Priority is defined in RFC 4021, 2.1.54, as a property that affects transmission speed and delivery ("normal", "urgent", and "non-urgent"). Importance is defined in RFC 4021, 2.1.52, as a property that is a hint from the originator to the recipients about how important a message is ("high", "normal", and "low").
For my use case, I'm targeting Outlook users and using MimeKit to build the emails. Importance is what most email clients care about, so here's what my code might look like:
using MimeKit;
var message = new MimeMessage();
message.Importance = MessageImportance.High;
I'll repost Steiger's links, because he's spot-on:
- https://www.iana.org/assignments/message-headers/message-headers.xhtml
- https://tools.ietf.org/html/rfc4021#page-32