邮件未收到用户

时间:2017-01-20 22:20:43

标签: c# asp.net

SELECT Table1.MemberID, Table1.BinaryIndicator,  IIf(Table1.MemberID=Table2.MemberID,"1",Table1.MemberID) AS IndicatorRevised
FROM Table1,Table2
GROUP BY Table1.MemberID,IndicatorRevised

用户没有收到电子邮件,Visual Studio也没有显示任何错误?我做错了什么?

3 个答案:

答案 0 :(得分:0)

我认为这与您的Gmail配置有关。点击here,然后选择“打开”。然后再试一次。

答案 1 :(得分:0)

尝试添加以下行:

smt.DeliveryMethod = SmtpDeliveryMethod.Network;
smt.UseDefaultCredentials = false;

答案 2 :(得分:0)

使用.Trim()时,可能看不到要发送的正确电子邮件地址,也可能为空。为项目添加一个断点,告诉我们操作它时的内容。您可以使用此代码;

    try
        {
           foreach (GridViewRow item in GridView1.Rows)
           {
             string Email_Address = item.Cells[1].Text.Trim();
             MailMessage msg = new MailMessage();
             msg.IsBodyHtml = true;
             msg.From = new MailAddress("khawarsaleem90@gmail.com");
             msg.To.Add(Email_Address);
             msg.Subject = TextBox1.Text;
             msg.Body = TextBox2.Text;
             SmtpClient smt = new SmtpClient("smtp.gmail.com", 587);
             smt.Credentials = new
             System.Net.NetworkCredential("khawarsaleem90@gmail.com", "mypass");
             smt.EnableSsl = true;
        try
            {
             smt.Send(msg);
             }

           catch (Exception ex)
              {
               throw new Exception(ex.Message.ToString());
              }
           }
        }
        catch (Exception ex)
        {

            throw new Exception(ex.Message.ToString());
        }