Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Email Priority with SendGrid API

Im using the SendGrid API in my Windows Azure environment to send emails. I have a need to alter the email priority (Low\High Importance) of some emails, but I don't see any properties that allow me to do this.

Does anyone have experience with SendGrid who knows how to change the priority? There is a property that allows me to add headers.. so Im not sure if that's something I can use to do this?

Thanks in advance!

like image 310
ewitkows Avatar asked Dec 25 '22 10:12

ewitkows


2 Answers

I was also looking for a way to mark email as important. After going through a couple of articles, I found the answer over here- https://github.com/sendgrid/sendgrid-csharp/issues/251

All you need to do is add priority in your mail headers. Like this-

mailMessage.Headers.Add("Priority", "Urgent");
mailMessage.Headers.Add("Importance", "high");

Code above works for high priority. I am guessing you would have to do something similar for low priority emails. Hope this helps.

like image 184
Pallavi Avatar answered Jan 12 '23 15:01

Pallavi


If you are using the Web API you can use the headers parameter as you mention. If sending via SMTP you can just add the headers to your message.

There are a few headers defined in RFC 4021 that support this as well as some custom ones. I'd use the following JSON for the headers parameter to start:

{“Priority”: “Urgent”, “Importance”: “high”}

If that doesn't work you can also look into the X-Priority and X-MSMail-Priority headers.

like image 33
bwest Avatar answered Jan 12 '23 16:01

bwest