1
:
using System.Net.Mail;
public static void SendWebMailAndAttach(string from,string to,string subject,string body)
{
SmtpClient Client = new SmtpClient("127.0.0.1");
Client.DeliveryMethod = SmtpDeliveryMethod.Network; //
用到了System.Net 命名空间
Client.Credentials = new System.Net.NetworkCredential("touch/weishuai ", "56");
//"touch/weishuai "
域用户
// "56"
密码
MailMessage Message = new MailMessage(from, to, subject, body);
Message.BodyEncoding = System.Text.Encoding.UTF8;
//Client.EnableSsl = true;
//Message.BodyEncoding = System.Text.Encoding.Unicode;
//Message.SubjectEncoding = System.Text.Encoding.Unicode;
Client.Send(Message);
Message.Dispose();
}
protected void Button1_Click(object sender, EventArgs e)
{
string from="vjsz_jingqiu@hotmail.com.cn";
string to="jingqiu95@yahoo.com.cn";
string subject="ni hao a ";
string body="yes good";
SendWebMailAndAttach(from,to,subject,body);
Response.Write("ok");
}
2.:
服务器拒绝了一个或多个收件人地址。服务器响应为
: 550 5.7.1 Unable to relay for ..................
默认
SMTP
虚拟服务器
--
属性
--
访问
--
中继
--“
加入
127.0.0.1”
;
就行了
就行了
3
:
System.Net.NetworkCredential("touch/weishuai", "56");
我在
SMTP
服务里设置了。
WIN
验证
属性
--
访问
--
访问控制
--
匿名和集成
WIN
验证
4 :注意杀毒软件的关闭。