做一个网站的Contact Us页面,提交以后的部分代码如下:MailMessage MyMail = new MailMessage();
MyMail.From = "[email protected]";
MyMail.To = "[email protected]";
MyMail.Subject = "Notice";
MyMail.Body = 表单信息;
MyMail.Cc = "";
MyMail.Bcc = "";
MyMail.UrlContentBase = "";
MyMail.UrlContentLocation = "";
MyMail.BodyEncoding = Encoding.UTF8;
MyMail.BodyFormat = MailFormat.Html;
MyMail.Priority = MailPriority.Normal;SmtpMail.Send(MyMail);感觉代码应该没有什么问题.在某些机器上运行正常,而有些机器上访问的时候,提交后收不到信.请问各位谁知道是什么原因?
MyMail.From = "[email protected]";
MyMail.To = "[email protected]";
MyMail.Subject = "Notice";
MyMail.Body = 表单信息;
MyMail.Cc = "";
MyMail.Bcc = "";
MyMail.UrlContentBase = "";
MyMail.UrlContentLocation = "";
MyMail.BodyEncoding = Encoding.UTF8;
MyMail.BodyFormat = MailFormat.Html;
MyMail.Priority = MailPriority.Normal;SmtpMail.Send(MyMail);感觉代码应该没有什么问题.在某些机器上运行正常,而有些机器上访问的时候,提交后收不到信.请问各位谁知道是什么原因?
解决方案 »
- WMEncoder 录屏双击事件无效
- 怎么用多线程加载一个类似等待的窗体?
- linkbutton的onclick如何调用script函数
- 下午就的交活,急!如何读取 .db 后缀格式的数据库文件(paradox的),谢谢!
- C#时间格式化
- Winform头一次做啊File.MoveTo方法为什么不好使啊???
- 关于datawindow.net回车转换为TAB的问题
- 用C#实现压缩操作的时候有点问题,压缩操作之后会在压缩包中多出路径的文件夹,怎么办?
- 求教在WEB中的简单问题!(关于对话框的,请各位大哥大姐帮帮忙!在线等待!)
- winfrom窗体问题
- 关于MessageBox返回值的问题
- C#里如何使用Timespan,请指教!
你可在C:\Inetpub\mailroot\Queue目录下看看有没有信件滞留.
MailMessage MyMail = new MailMessage();
MyMail.From = "[email protected]";
MyMail.To = "[email protected]";
MyMail.Subject = "Notice";
MyMail.BodyFormat =MailFormat.Text;
MyMail.Body = "表单信息";
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "zhang san"); //set your username here
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "123456"); //set your password here
SmtpMail.SmtpServer ="smtp.163.com";
SmtpMail.Send(MyMail);
try
{
SmtpMail.Send(message);
}
catch( System.Web.HttpException exHttp )
{
//
}
我这个反正是运行好好的.(邮件地址改)
另:邮件服务器配置得注意
This step-by-step article describes how to set up a Simple Mail Transfer Protocol (SMTP) virtual server on a Windows XP-based computer. Microsoft SMTP Service uses the Internet-standard SMTP to transport and deliver mail messages. Microsoft SMTP Service does not support the use of individual mailboxes; it places incoming messages in a Drop folder or it forwards them to other SMTP servers (if the message is addressed to a remote domain). This feature allows Microsoft SMTP Service to be used as a mail receiver for other programs.
Install Microsoft Internet Information Services (IIS) and Microsoft SMTP Service
Because Microsoft SMTP Service is a component of Microsoft Internet Information Services (IIS), you must install IIS to use Microsoft SMTP Service. To install IIS and Microsoft SMTP service, follow these steps:
1. Click Start, point to Settings, and then click Control Panel.
2. Double-click Add/Remove Programs.
3. Click Add/Remove Windows Components.
4. In the Windows Components Wizard, click Internet Information Services (IIS), and then click Details.
5. Click to select the following check boxes:
• Common Files
• Documentation
• Internet Information Services Snap-In
• SMTP Service
• World Wide Web Server
6. Click OK, and then click Next on the Windows Components page.
7. On the Completing the Windows Components Wizard page, click Finish.
8. Click Close. Configure the SMTP Virtual Server
When you install Microsoft SMTP Service, a default SMTP virtual server is created to handle basic mail delivery functions. The SMTP virtual server is automatically configured with default settings that enable it to accept local client computer connections and to process messages. You can accept the default settings only need change a little.To grant or deny permissions to relay messages through the SMTP virtual server, follow these steps:
1. Click Start, point to Programs, point to Administrative Tools, and then click Internet Services Manager.
2. Alternatively, start the IIS snap-in.
3. Right-click Default SMTP Virtual Server, and then click Properties.
4. Click the Access tab.
5. Under Relay restrictions, click Relay.
6. Please select the second option:
• Click Only the list below.
• Click All except the list below.
7. click OK .