反馈表尽管代码工作正常,但我没有收到邮件 [英] Feedback Form I am not receiving mail though the codes are working fine

查看:92
本文介绍了反馈表尽管代码工作正常,但我没有收到邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我到目前为止使用的代码.
它发送邮件,但我没有收到邮件.
请帮忙.




Below is my code which i used so far.
It sends mail but i am not receiving mail.
Please help.




protected void Button1_Click(object sender, EventArgs e)
{
  SmtpClient smtpclient = new SmtpClient();

  MailMessage message = new MailMessage();

  smtpclient.Host = "smtp.gmail.com";
  smtpclient.Port = 587;

  try
  {
    MailAddress SendFrom = new MailAddress(T1.Text);
    MailAddress SendTo = new MailAddress(T2.Text);
    MailMessage MyMessage = new MailMessage(SendFrom, SendTo);
    MyMessage.Subject = T3.Text;
    MyMessage.Body =T4.Text;
    T5.Text = "Message Sent";
  }
  catch (Exception ex)
  {
    T5.Text = ex.ToString();
  }
}

推荐答案

在此代码中实际上没有发送电子邮件.这是SmtpClient对象的功能.

有关SmtpClient.Send(MailMessage)方法的信息. [ ^ ]

要从您的代码发送消息,您需要行smtpclient.Send(message).我不知道在执行此操作之前是否需要对SmtpClient对象进行任何其他配置,但这将使您朝正确的方向前进.
Nowhere in this code are you actually sending the email. That''s a function of the SmtpClient object.

Here''s info on the SmtpClient.Send(MailMessage) method.[^]

To send the message from your code, you''d need the line smtpclient.Send(message). I don''t know if there''s any further configuration you''ll need to do on your SmtpClient object before you do this, but it''ll get you headed in the right direction.


这篇关于反馈表尽管代码工作正常,但我没有收到邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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