发送电子邮件问题 [英] sending email problem

查看:143
本文介绍了发送电子邮件问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我的网站有严重问题.
我曾经使用某种代码在我的网站中发送电子邮件.问题是该代码在一页上正常工作,而在另一页上不工作.
我完全困惑.
和web.config后面的代码:


MailMessage mail = new MailMessage();
 mail.From = new MailAddress("contacts@website.com");
 mail.To.Add(DropDownList1.SelectedValue);
mail.Subject = txtSubject.Text;
 mail.Body = "<div>something...</div>";
 mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("mailserver.com");
smtp.Credentials = new NetworkCredential("contacts@website.com","password");
smtp.Send(mail);





韦伯C O N F I G

<pre lang="xml"><system.net>
    <mailSettings>
      <smtp>
        <network defaultCredentials="false"/>
      </smtp>
    </mailSettings>
  </system.net>






每一个解决方案将不胜感激
谢谢

你的意思是代码在一页上有效而在另一页上无效,可能是文件后面代码上的复制粘贴问题,是否检查了控件id,正确包含名称空间,放置断点并查看是否有合适的值

hi everybody,
i have serious problem in my web site.
i had use some sort of code to send email in my website.the problem is that code works properly in one page and don''t work on the other page.
i''m completely confused.
the code behind and web.config :


MailMessage mail = new MailMessage();
 mail.From = new MailAddress("contacts@website.com");
 mail.To.Add(DropDownList1.SelectedValue);
mail.Subject = txtSubject.Text;
 mail.Body = "<div>something...</div>";
 mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("mailserver.com");
smtp.Credentials = new NetworkCredential("contacts@website.com","password");
smtp.Send(mail);





W E B . C O N F I G

<pre lang="xml"><system.net>
    <mailSettings>
      <smtp>
        <network defaultCredentials="false"/>
      </smtp>
    </mailSettings>
  </system.net>






every solution will be appreciated
thanks

解决方案

Hi What you mean by code works on one page and not in other page may be it is copy paste problem on code behind file, did you check the control ids, namespace included properly, place break point and see whether proper values are coming


这篇关于发送电子邮件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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