日期:2014-05-20  浏览次数:20359 次

急求asp.net发送邮件与接收邮件代码望高手们帮忙
急求asp.net"发送邮件"与"接收邮件"代码望高手们帮忙, 在线等`````

------解决方案--------------------
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Net.Mail; 

public partial class Default3 : System.Web.UI.Page 

protected void Page_Load(object sender, EventArgs e) 

MailAddress MessageFrom = new MailAddress("itcaimeng@gmail.com"); //发件人邮箱地址 
string MessageTo = "lwjdg@126.com"; //收件人邮箱地址 
string MessageSubject = "测试例子"; //邮件主题 
string MessageBody = "测试的例子终于成功了,很开心啊!"; //邮件内容 
if (Send(MessageFrom, MessageTo, MessageSubject, MessageBody)) 

Response.Write("发送邮件成功"); 

else 

Response.Write("发送邮件失败"); 


/// <summary> 
/// 发送电子邮件 
/// </summary> 
/// <param name="MessageFrom">发件人邮箱地址 </param> 
/// <param name="MessageTo">收件人邮箱地址 </param> 
/// <param name="MessageSubject">邮件主题 </param> 
/// <param name="MessageBody">邮件内容 </param> 
/// <returns> </returns> 
public bool Send(MailAddress MessageFrom, string MessageTo, string MessageSubject, string MessageBody) 

MailMessage message = new MailMessage(); 
message.From = MessageFrom; 
message.To.Add(MessageTo); //收件人邮箱地址可以是多个以实现群发 
message.Subject = MessageSubject; 
message.Body = MessageBody; 
message.IsBodyHtml = true; //是否为html格式 
message.Priority = MailPriority.High; //发送邮件的优先等级 

SmtpClient sc = new SmtpClient(); 
sc.Host = "smtp.gmail.com"; //指定发送邮件的服务器地址或IP 
//sc.Port = 587; //指定发送邮件端口 
sc.UseDefaultCredentials = true; 
sc.EnableSsl = true; 
sc.Credentials = new System.Net.NetworkCredential("itcaimeng", "19881028"); //指定登录服务器的用户名和密码 
try 

sc.Send(message); //发送邮件 

catch(Exception e) 

Response.Write(e.Message); 
return false; 

return true; 

}
------解决方案--------------------
http://download.csdn.net/source/512772
http://www.51aspx.com/CV/WebMail/
http://www.diybl.com/course/4_webprogram/asp.net/asp_netshl/2008118/96685.html
------解决方案--------------------
sending email is pretty simple: 

MailMessage mail = new MailMessage(); 
mail.From = ""; // put the from address here 
mail.To = ""; // put to address here 
mail.Subject = ""; // put subject here 
mail.Body = ""; // put body of email here 
SmtpMail.SmtpServer = ""; // put smtp server you will use here 
// and then send the mail 
SmtpMail.Send(mail); 

------解决方案--------------------