0

我的网站中有功能可以向 id 发送电子邮件.. 电子邮件包含指向网页的链接和安全密钥.. 但问题是它进入了垃圾文件夹

我正在使用 Somee.com 的免费托管

代码:

MailMessage message = new MailMessage();
message.IsBodyHtml = true;

message.Body = ("Copy The Link  And paste It In Them follow Link <a href=\"http://localhost:52567/fu/Download.aspx\"> Download </a> </br>"+ encoded_url);
message.From = new MailAddress("lz-wag@hotmail.com");
message.To.Add(TextBox2.Text);
message.Subject = user + " Has Share The File With You";


try{
SmtpClient client = new SmtpClient();
client.Host = "smtp.live.com";

client.EnableSsl = true;
System.Net.NetworkCredential networkcred = new System.Net.NetworkCredential();
networkcred.UserName =  "lz-wag@hotmail.com";
networkcred.Password = "password";

client.Port = 587;
client.Credentials = networkcred;
client.Send(message);
sendFile.Visible = false;
Label1.Visible = true;
Label1.Text = "Your File Has Been Shared";


}

catch(Exception ex){
    Label1.Visible = true;
   Label1.Text = "Your File Is Not Shared";
   //Label1.Text = ex.ToString(); ;
}
4

1 回答 1

2

电子邮件是否进入垃圾邮件文件夹是电子邮件客户端的功能,而不是您发送电子邮件的方式。

但是,仅供参考, theMailMessageSmtpClientimplement IDisposable,所以应该在using块中。像这样的东西:

using (MailMessage message = new MailMessage())
{
    // ...
    using (SmtpClient client = new SmtpClient())
    {
        // ...
        client.Send(message);
    }
}

我还建议您将异常记录在某个地方,否则当出现问题时您将永远不知道出了什么问题。

于 2013-11-05T14:34:20.837 回答