Prageeth Liyanage
Prageeth Liyanage

Reputation: 1772

How to set X-Entity-Ref-ID to no value? ( Regarding prevent email thredding )

I am developing website by using ASP.net. In there I am firing several emails to user. Probelem is all the emails are grouping( Threading) I want to stop this.

I found a post regarding this on

Force emails not to be grouped into conversations

In there it says

  • set X-Entity-Ref-ID header (no value needed). This is what Google+ notifications do.

  • change the sender email (you can use From: [email protected]). This is what Facebook notifications
    do.

I dont think 2nd idea is a good thing. But I want to try the first thing. How to do it? Where I can find this attribute?

Upvotes: 1

Views: 2473

Answers (1)

RickL
RickL

Reputation: 3403

I'm using nuget package Postal for sending emails in both html and text formats. For that, there is an email header file (holding "from" and "to" info). Adding X-Entity-Ref-ID: HeaderId, where HeaderId is a guid, to this file (before the From: and To: parameters) works. Give a unique reference value to X-Entity-Ref-ID, rather than no value.

You may well not be using Postal but this approach may work for other packages as well.

In the Controller:

var emailModel = new EmailModel()
{
   To = user.UserName, // user is your User entity
   // Text replacement to stop Gmail showing mailto tag
   UserName = user.UserName.Replace("@", "<span>@</span>").Replace(".", "<span>.</span>"),
   // HeaderId to insert a guid into X-Entity-Ref-ID header to prevent Gmail threading
   HeaderId = new Guid()
};

emailModel.Send();

and then, in the email header file:

X-Entity-Ref-ID: @Model.HeaderId // This assigns a unique value
To: @Model.To
From: ThisCo <[email protected]>
Subject: The Email Subject
Views: Text, Html

with the EmailModel defined as:

public class SignupLinkEmail : Email // inheriting from the nuget Postal Email class
{
    public string To { get; set; }
    public string UserName { get; set; }
    public Guid HeaderId { get; set; }
    // other things ..
}

Upvotes: 1

Related Questions