473,395 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Email Tracking Using ASP.NET not working

24
I have a problem tracking emails.I want to know who read my email.When i send mail to my outlook it works fine but when i want to send it across the network it does not work.ie. When i debug my code and give path of localhost it works but when i give path of my PC on the network it does not work i have hosted the website on IIS locally.Here is my PC name and port where i have configured it PC-50:102
Here is code.
Http Module
Expand|Select|Wrap|Line Numbers
  1. public class HttpModuleClass : IHttpModule
  2.     {
  3.         //public event EventHandler BeginRequest;
  4.  
  5.         public void Dispose()
  6.         {
  7.  
  8.         }
  9.  
  10.         /// <summary>
  11.         /// public varibles
  12.         /// </summary>
  13.         string footerFile = "~/images/footer.png";
  14.         //string footerFile = "~/images/ajax-loader.gif";
  15.         Email_Calls bl_email_calls = new Email_Calls();
  16.  
  17.         /// <summary>
  18.         /// Init methoed
  19.         /// </summary>
  20.         /// <param name="context"></param>
  21.         public void Init(HttpApplication context)
  22.         {
  23.             context.BeginRequest += new System.EventHandler(GetImage_BeginRequest);
  24.         }
  25.  
  26.         /// <summary>
  27.         /// handles requests made to server and call update email read time
  28.         /// </summary>
  29.         /// <param name="sender"></param>
  30.         /// <param name="args"></param>
  31.         public void GetImage_BeginRequest(object sender, System.EventArgs args)
  32.         {
  33.             //cast the sender to a HttpApplication object
  34.             System.Web.HttpApplication application = (System.Web.HttpApplication)sender;
  35.             string url = application.Request.Path; //get the url path
  36.  
  37.             string pattern = @"/images/(?<key>.*)\.aspx";
  38.  
  39.              //create the regex to match for beacon images
  40.             Regex r = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
  41.             if (r.IsMatch(url))
  42.             {
  43.                 MatchCollection mc = r.Matches(url);
  44.                 if ((mc != null) && (mc.Count > 0))
  45.                 {
  46.                     string key = (mc[0].Groups["key"].Value);
  47.                     bl_email_calls.UpdateSystemEmailAuditReadDate(key);
  48.  
  49.                 }
  50.  
  51.                 //now send the REAL image to the client
  52.                 //application.Response.ContentType = "image/gif";
  53.                 application.Response.ContentType = "image/png";
  54.                 application.Response.WriteFile(application.Request.MapPath(footerFile));
  55.  
  56.                 //end the response
  57.                 application.Response.End();
  58.             }
  59.         }
  60.     }
  61.  
And here is code which is creating all the mess
Expand|Select|Wrap|Line Numbers
  1.      string emailTemplateBody = TextArea1.Value;
  2.         //This works
  3. //emailTemplateBody += "<br /><img style='opacity:0.0; filter:alpha(opacity=0);' src=http://localhost:50421/HttpModule_using_beacon_images-Copy/images/<keyvalue>.aspx   />";
  4.  
  5. //This does not works
  6. emailTemplateBody += "<br /><img src=http://PC-50:102/images/<keyvalue>.aspx style='opacity:0.0; filter:alpha(opacity=0);'  />";
  7.  
  8.            string templateName = txtTemplateName.Text;
  9.  
  10.  
  11.            string toEmail=txtTo.Text;
  12.  
  13.  
  14.            //// Get unique Key after registring mail to be sent
  15.            string key = bl_email_calls.RegisterSystemEmailAudit("1", templateName, DateTime.Now);
  16.  
  17.  
  18.            emailTemplateBody = emailTemplateBody.Replace("<keyvalue>", key);
  19.            //// sending e-mail
  20.            bl_email_calls.SendMailMessage(toEmail, templateName, emailTemplateBody, key);
  21.            using (var cn = new SqlConnection(ConfigurationManager.ConnectionStrings["webConnectionString"].ToString()))
  22.            {
  23.                var cmd = new SqlCommand("insert into dr_emailtemplate (Practice_Code ,Template_Name ,TemplateBody ,Created_By ,Created_Date)" +
  24.                    "values('" + 1010 + "', '" + templateName + "', '" + "Test Body" + "', 'Mairaj " + key + "', getdate())", cn);
  25.                cn.Open();
  26.                cmd.ExecuteNonQuery();
  27.                cn.Close();
  28.            }
Please help.
Frinny please help.
Jun 14 '12 #1

✓ answered by Maraj

Well i solved this too.Actually i was using IIS 7 and configuration for IIS is bit different.I was using <httpmodule>
tags in web.config but IIS was not reading it.IIS 7 reads <module> tags so i added it and it worked.

1 2485
Maraj
24
Well i solved this too.Actually i was using IIS 7 and configuration for IIS is bit different.I was using <httpmodule>
tags in web.config but IIS was not reading it.IIS 7 reads <module> tags so i added it and it worked.
Jun 24 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: johnny | last post by:
hi ! I use to track ( with an image with id attached to its link ) the opening of some html messages ( don't worry I am not a spammer,they are newsletters sent to the salesforce ). Today I...
1
by: Developer | last post by:
We have a need to track our customers opening the HTML emails that we send out to them. As soon as the customer opens the HTML email that we send out we need to make an entry in the database with...
2
by: Rashid Khan | last post by:
Honoured Sir! I want to provide email facility using asp 3.0, IIS 5.0 in windows xp plateform. When I use CDONTS, I get an error message...invalid string or something like this..Is there any way...
1
by: dave | last post by:
hi guys I m trying to execute few lines code tht i have copies from microsoft tech script centre. basically its to send email without using any smtp service. u can find the code snippet from...
2
by: anony | last post by:
Maybe this feature is already out there. I guess you could write triggers to do some of this. Often when designing a database I add a start_date and end_date column to the table. The start_date...
1
by: Just D. | last post by:
All, What is the simplest way to send an email message through the MS SQL Server? There was a method to send email messages using a standard C# way via SMTP server, but the required port was...
6
by: ErwinF | last post by:
Hi there, I would like to know the following: How to send send email attachments using WebDAV in VB .NET? Sample code please................... Thanks for your help.
1
by: zxon | last post by:
I want to be able to track when recipients have opened an email that I have sent to them using JMail. I've searched the internet for a solution and so far cannot find one. I've found these two...
2
by: kash1987 | last post by:
Hi, Let me first explain what i am trying to do: step 1 : domain-a.com -> cookie is set using a redirecting PHP script(placed on domain-b.com) when a link to domain-b.com is clicked from this...
1
by: Sidhu v | last post by:
How can create email id using shell_exec or exec in php.That is ,i want to create email id in my web application. anybody can help me. Thanks and regards By Sidhu
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.