反馈表尽管代码工作正常,但我没有收到邮件

编程入门 行业动态 更新时间:2024-10-14 10:41:11
本文介绍了反馈表尽管代码工作正常,但我没有收到邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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.

更多推荐

反馈表尽管代码工作正常,但我没有收到邮件

本文发布于:2023-11-07 23:24:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1567716.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:但我   反馈   邮件   代码   工作

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!