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 + "
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.
No comments:
Post a Comment