日期:2014-05-18  浏览次数:20518 次

asp.net把提交的数据发送到邮箱。
asp.net把提交的数据发送到邮箱。请问该如何实现?急

------解决方案--------------------
利用System.Web.Mail命名空间里的MailMessage;

C# code
MailMessage myMail= new MailMessage();   
myMail.From = "...";   
myMail.To = "...";   
myMail.Subject = "回复:"+titleTextBox.ToString();   
myMail.Body=reTextBox.ToString();

------解决方案--------------------
public void CDOsendMail(string f_email,string t_email,string zh,string mm)
{
try
{
CDO.Message oMsg = new CDO.Message();

oMsg.From = f_email;
oMsg.To = t_email;
oMsg.Subject = "东风威客取回密码";

oMsg.HTMLBody = "<html><body>这是您的帐号信息:<br>帐号:"+zh+"<br>密码:"+mm+"<br><a href='http://www.33419.cn'>东风工作室</a></body></html>";



CDO.IConfiguration iConfg = oMsg.Configuration;
ADODB.Fields oFields = iConfg.Fields;

oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"].Value=2;
oFields["http://schemas.microsoft.com/cdo/configuration/sendemailaddress"].Value=f_email; //sender mail
oFields["http://schemas.microsoft.com/cdo/configuration/smtpaccountname"].Value=f_email; //email account
oFields["http://schemas.microsoft.com/cdo/configuration/sendusername"].Value="roamabout";
oFields["http://schemas.microsoft.com/cdo/configuration/sendpassword"].Value="kk123"; 
oFields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"].Value=1;
//value=0 代表Anonymous验证方式(不需要验证)
//value=1 代表Basic验证方式(使用basic (clear-text) authentication. 
//The configuration sendusername/sendpassword or postusername/postpassword fields are used to specify credentials.)
//Value=2 代表NTLM验证方式(Secure Password Authentication in Microsoft Outlook Express)
oFields["http://schemas.microsoft.com/cdo/configuration/languagecode"].Value=0x0804;
oFields["http://schemas.microsoft.com/cdo/configuration/smtpserver"].Value="smtp.126.com";



oFields.Update();
oMsg.BodyPart.Charset="gb2312";
oMsg.HTMLBodyPart.Charset="gb2312"; 



oMsg.Send();
oMsg = null;
}
catch (Exception e)
{
throw e;
}
}

再添加一个引用,如果你是xp系统请到c:\windiws下找到cdosys.dll,如果是2000到c:\winnet找cdosys.dll(不要说不会添加引用吧???)