Tracking Emails - Know Whether the Recipient Opens it

It is very easy to track whether the user has read the email. The concept is very simple. You insert a link to a small transparent image in the mail sent, the mail being sent in HTML format, and when the user opens the email the image is loaded sending you a querystring to the web page that tracks the email. The web page requests the querystring or the parameter that is passed. This ensures that the email is read by the user.


When the page that is tracking is requested by the email sent you can get the value of the date and time when the request comes and you can store them in a database or send you an alert indicating the time and date at which the email was read by the user. This is the simple way that is used to track whether the emails sent are read or not.

To send emails you may be importing the namespace System.Web.Mail. You would be creating a MailMessage object as given below.

Imports System.Web.Mail

string sBody;

MailMessage mailMsg = new MailMessage();

mailMsg.BodyFormat = MailFormat.Html;
SmtpMail.SmtpServer = “your Server name”;
mailMsg.From = "your email address";
mailMsg.To = “to email address”;
mailMsg.Subject = “subject line of the mesg”;
mailMsg.Body = sBody;
SmtpMail.Send(mailMsg);

The above code sends an email to an email address as given in the mailMsg.To property. For tracking an email, all you have to do is to add an image tag to the body of the message i.e. sBody. This can be done by

sBody = sBody + "<IMG height=1 src=\"http://www." + sYourDomain + "/trackemail.aspx?sentto=" + sParam + "\" width=1>";

In the above line sParam is the parameter that is passed to the url and sYourDomain is your domain name where you create this page to track the email. If you send an email with the body of the message as given above, when the user reads the email, the image tag will try to load the url given in the tag. This will send the parameter “sentto” that is given by you to the page requested. In the trackemail.aspx page you can write code to retrieve the value of the parameter “sentto”. Once you receive the parameter you can do anything on that page to indicate that the user has read the email.

The code given below can be used in the trackemail.aspx page to retrieve the parameter.

private void Page_Load(object sender, System.EventArgs e)
{
if ( Page.IsPostBack == false )
{
if ( Request.Params["sentto"] != null )

//here you can send a mail to yourself
...
mailMsg.Body = Request.Params["sentto"].ToString()
+ “ has read your email”;
...

}

Response.Redirect("transparent.gif");
}

Once you have retrieved the parameter that is passed to the page you can redirect the request to a transparent image so that this transparent image, “transparent.gif” loads in the email message of the user who is reading the mail. Make this “transparent.gif” as small as possible, usually of 1 pixel by 1 pixel height and width, so that it does not take time to load. Since it is transparent the user who reads your mail may not know that an image has been loaded in the email message and the email that he reads is being tracked.

This way of tracking the email is so easy. Once you get the parameter in your trackemail.aspx page you can add a time stamp to the body of the email message that is sent to you in the Page_Load event of that page. This enables you to know the time and date at which the email was read by the user.

_______________________________________________________________________

Add to My Yahoo!


FREE Subscription

Subscribe to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.

Name:
Email:

Note : We never rent, trade, or sell my email lists to
anyone. We assure that your privacy is respected
and protected.

Visit .NET Programming Tutorial Homepage

______________________________________________________

Recommended Resource


| Privacy Policy for www.dotnet-guide.com | Disclosure | Contact |

Copyright - © 2004 - 2017 - All Rights Reserved.