本文介绍了反馈表尽管代码工作正常,但我没有收到邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我到目前为止使用的代码. 它发送邮件,但我没有收到邮件. 请帮忙.
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"; 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.
更多推荐
反馈表尽管代码工作正常,但我没有收到邮件
发布评论