Verfolgen Sie, ob gesendete E-mail gelesen wird oder nicht

Den ich gesucht habe viele Artikel und haben einige code, aber es funktioniert nicht für mich.

Meinem index.aspx.cs-Seite-code:

 protected void Page_Load(object sender, EventArgs e)
 {
    if (checkIfRequested(this.Context.Request))
    {           
        //receiver had already requested the image, hence send back a not modified result
        Response.StatusCode = 304;
        Response.SuppressContent = true;
    }
    else
    {
        int emailId = 0;
        if (!string.IsNullOrEmpty(Request.QueryString["emailId"]) && int.TryParse(Request.QueryString["emailId"], out emailId))
        {
            Session["image"] = Request.QueryString["emailId"];
            lblid.Text = Convert.ToString(Session["image"]);


            //The email with emailId has been opened, so log that in database
        }
        else
        {
            if (Request.QueryString["emailId"] != null)
            {
                lblid.Text = Convert.ToString(Request.QueryString["emailId"]);
            }
            string str = "<script>alert('empty')</script>";
            Page.RegisterStartupScript("popup", str);
        }

        //Send the single pixel gif image as response
        byte[] imgbytes = Convert.FromBase64String("R0lGODlhAQABAIAAANvf7wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==");
        Response.ContentType = "image/gif";
        Response.AppendHeader("Content-Length", imgbytes.Length.ToString());
        Response.Cache.SetLastModified(DateTime.Now);
        Response.Cache.SetCacheability(HttpCacheability.Public);
        Response.BinaryWrite(imgbytes);
    }
}

private bool checkIfRequested(HttpRequest req)
{
    //check if-modified-since header to check if receiver has already requested the image in last 24 hours
    return req.Headers["If-Modified-Since"] == null ? false : DateTime.Parse(req.Headers["If-Modified-Since"]).AddHours(24) >= DateTime.Now;
}

Meinem index.aspx-Seite scheint, als:

<body>
<form id="form1" runat="server">
<asp:Label ID="lblid" runat="server" Text=""></asp:Label>   
</form>
</body>

Ich verwendet, um E-Mail senden zu meinem eigenen Gmail-id von meiner aspx-Seite wie:

String MailContent = "";
MailContent += "<img src='http://WWW.mywebsitename.com/index.aspx?emailId=1' width='1' height='1' />
client = new SmtpClient();
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("Myemailidofhmail", "mypassword");
client.Port = 25;
client.Host = "smtp.gmail.com";
client.EnableSsl = true; 
mailto = "[email protected]";
message = MailContent.ToString();
msg = new System.Net.Mail.MailMessage();
msg.To.Add(mailto);

Hier die mail kommt erfolgreich auf mein Gmail-Konto auf [email protected] - id, aber wenn ich Sie öffnen E-Mails von meinem Konto ich bin nicht immer Request.QueryString["emailId"] Wert als 1 zu meinem index.aspx

Die ein-pixel-Bild-System für tracking-E-Mail-Nachrichten wird weitgehend blockiert E-Mail-clients. Speziell, Gmail dient alle Bilder auf E-Mail-Benutzer von einem proxy-server. Ihre single-pixel-Schema funktioniert einfach nicht.
also was muss ich jetzt tun?

InformationsquelleAutor | 2014-02-18

Schreibe einen Kommentar