asp.net实现邮件的发送
1
try
2
{
3
CDO.Message Msg = new CDO.Message();
4
Msg.From = "YY@sohu.com";
5
Msg.To = "XX@sohu.com";
6
Msg.Subject = "主题";
7
Msg.HTMLBody = "<html><body>" + "内容"
8
+ "</body></html>";
9
CDO.IConfiguration Config = Msg.Configuration;
10
ADODB.Fields oFields = Config.Fields;
11
oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"].Value = 2;
12
oFields["http://schemas.microsoft.com/cdo/configuration/sendemailaddress"].Value = "YY@sohu.com";
13
oFields["http://schemas.microsoft.com/cdo/configuration/smtpaccountname"].Value = "YY@sohu.com";
14
oFields["http://schemas.microsoft.com/cdo/configuration/sendusername"].Value = "YY";
15
oFields["http://schemas.microsoft.com/cdo/configuration/sendpassword"].Value = "password";
16
oFields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"].Value = 1;
17
oFields["http://schemas.microsoft.com/cdo/configuration/languagecode"].Value = 0x0804;
18
oFields["http://schemas.microsoft.com/cdo/configuration/smtpserver"].Value = "smtp.sohu.com";
19
oFields.Update();
20
Msg.BodyPart.Charset = "gb2312";
21
Msg.HTMLBodyPart.Charset = "gb2312";
22
Msg.Send();
23
Msg = null;
24
}
25
catch (Exception err)
26
{
27
throw err;
28
}[ftc=#EE1D24]<font color=red></font>[/ft]
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
17
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
18
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
20
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
22
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
23
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
24
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
25
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
26
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
27
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
28
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)