使用ASP.NET的电子邮件跟踪不起作用 [英] Email Tracking Using ASP.NET not working

查看:77
本文介绍了使用ASP.NET的电子邮件跟踪不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在跟踪电子邮件时遇到问题.我想知道谁阅读了我的电子邮件.当我将邮件发送到Outlook时,它可以正常工作,但是当我想通过网络发送时,它就无法工作.当我调试代码并提供本地主机的路径时,它可以工作,但是当我在网络上提供我的PC的路径时,我无法在本地IIS上托管网站.这是我在PC上配置它的PC名称和端口- 50:102

这是代码.
Http模块

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

public class HttpModuleClass : IHttpModule
    {
        //public event EventHandler BeginRequest;

        public void Dispose()
        {

        }

        /// <summary>
        /// public varibles
        /// </summary>
        string footerFile = "~/images/footer.png";
        //string footerFile = "~/images/ajax-loader.gif";
        Email_Calls bl_email_calls = new Email_Calls();

        /// <summary>
        /// Init methoed
        /// </summary>
        /// <param name="context"></param>
        public void Init(HttpApplication context)
        {
            context.BeginRequest += new System.EventHandler(GetImage_BeginRequest);
        }
        
        /// <summary>
        /// handles requests made to server and call update email read time
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void GetImage_BeginRequest(object sender, System.EventArgs args)
        {
            //cast the sender to a HttpApplication object
            System.Web.HttpApplication application = (System.Web.HttpApplication)sender;
            string url = application.Request.Path; //get the url path
            
            string pattern = @"/images/(?<key>.*)\.aspx";
            
             //create the regex to match for beacon images
            Regex r = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
            if (r.IsMatch(url))
            {
                MatchCollection mc = r.Matches(url);
                if ((mc != null) && (mc.Count > 0))
                {
                    string key = (mc[0].Groups["key"].Value);
                    bl_email_calls.UpdateSystemEmailAuditReadDate(key);

                }

                //now send the REAL image to the client
                //application.Response.ContentType = "image/gif";
                application.Response.ContentType = "image/png";
                application.Response.WriteFile(application.Request.MapPath(footerFile));

                //end the response
                application.Response.End();
            }
        }
    }


这是创建所有混乱的代码


And here is code which is creating all the mess

           string emailTemplateBody = TextArea1.Value;
        //This works
//emailTemplateBody += "<br /><img style='opacity:0.0; filter:alpha(opacity=0);' src=http://localhost:50421/HttpModule_using_beacon_images-Copy/images/<keyvalue>.aspx   />";

//This does not works
emailTemplateBody += "<br /><img src=http://it-83:302/images/<keyvalue>.aspx style='opacity:0.0; filter:alpha(opacity=0);'  />";

           string templateName = txtTemplateName.Text;


           string toEmail=txtTo.Text;


           //// Get unique Key after registring mail to be sent
           string key = bl_email_calls.RegisterSystemEmailAudit("1", templateName, DateTime.Now);


           emailTemplateBody = emailTemplateBody.Replace("<keyvalue>", key);
           //// sending e-mail
           bl_email_calls.SendMailMessage(toEmail, templateName, emailTemplateBody, key);
           using (var cn = new SqlConnection(ConfigurationManager.ConnectionStrings["webConnectionString"].ToString()))
           {
               var cmd = new SqlCommand("insert into dr_emailtemplate (Practice_Code ,Template_Name ,TemplateBody ,Created_By ,Created_Date)" +
                   "values('" + 1010 + "', '" + templateName + "', '" + "Test Body" + "', 'Mairaj " + key + "', getdate())", cn);
               cn.Open();
               cmd.ExecuteNonQuery();
               cn.Close();
           }


请帮忙.


Please help.

推荐答案

您正在使用PC-50:102,但是在您的代码中却使用了它-83:302?

选中此 [ ^ ]]
You are using PC-50:102 but in your code you have used it-83:302 ?

Check this [Receive Email Read Notification and Save It in Database[^]]


这篇关于使用ASP.NET的电子邮件跟踪不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆