Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add unsubscribe link as shows in below image

I've written code in C# that send mail to number of users. The email is in HTML format and contains a unsubscribe link.

What I want to do is, have unsubscribe link as shown in image... enter code here

To add more information, I'm using SendGrid for sending emails to end users.

I viewed raw message format in Gmail and I can see Header there in format

List-unsubscribe: <https..../usersettings?SubscriberId=VioR5IcgvSIosfB1w%2FCPfhpyGBdko%2BxsmFTAsQAemuWgSJkpTP1UeDg%2BW4frl59A0KVVpiK0lI7IrS3N1BCm0Sspd0dqEaJGlKHAY3g7IR3INwkyJEAmfU55TBJ8uEo%3D>

Yet the link is not displayed. What am I missing?

like image 300
Hiren Desai Avatar asked Oct 16 '22 12:10

Hiren Desai


1 Answers

You have to add that link in your email header something like this

mailMessage.Headers.Add("List-Unsubscribe", String.Format(
    CultureInfo.InvariantCulture, "<http://{0}>", unSubscribeUrl));
like image 192
Tech Yogesh Avatar answered Oct 20 '22 22:10

Tech Yogesh