1using System;
2using System.Data;
3using System.Configuration;
4using System.Collections;
5using System.Web;
6using System.Web.Security;
7using System.Web.UI;
8using System.Web.UI.WebControls;
9using System.Web.UI.WebControls.WebParts;
10using System.Web.UI.HtmlControls;
11using System.Web.Mail;
12
13public class SendMail
14{
15 string tb_from;
16 string tb_to;
17 string tb_mailBody;
18 string tb_smtpserver;
19 string tb_body;
20 string tb_sub;
21 public SendMail(string to, string body, string sub)
22 {
23 tb_to = to.Trim();
24 tb_body = body.Trim();
25 tb_sub = sub.Trim();
26 }
27
28 public void sengmill_net()
29 {
30 tb_from = "xxxx@21cn.com";
31 tb_mailBody = tb_body;
32 tb_smtpserver = "smtp.21cn.com";
33 System.Web.Mail.MailMessage mailmsg = new System.Web.Mail.MailMessage();
34 mailmsg.From = tb_from;
35 mailmsg.To = tb_to;
36 mailmsg.Body = tb_mailBody;
37 mailmsg.Subject = tb_sub;
38 mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
39 //是否需要验证,一般是要的
40 mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "xxxxx");
41 //自己邮箱的用户名
42 mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "xxxxx");
43 //自己邮箱的密码
44 System.Web.Mail.SmtpMail.SmtpServer = tb_smtpserver;
45 System.Web.Mail.SmtpMail.Send(mailmsg);
46 }
47}
48
49public partial class bank : System.Web.UI.Page
50{
51 protected void Page_Load(object sender, EventArgs e)
52 {
53
54 }
55 protected void btnSend_Click(object sender, EventArgs e)
56
57 {
58 ////调用代码
59 SendMail t=new SendMail(xxx@xxx.com,"文本内容","标题内容");
60 t.sengmill_net();
61 }
62}
2using System.Data;
3using System.Configuration;
4using System.Collections;
5using System.Web;
6using System.Web.Security;
7using System.Web.UI;
8using System.Web.UI.WebControls;
9using System.Web.UI.WebControls.WebParts;
10using System.Web.UI.HtmlControls;
11using System.Web.Mail;
12
13public class SendMail
14{
15 string tb_from;
16 string tb_to;
17 string tb_mailBody;
18 string tb_smtpserver;
19 string tb_body;
20 string tb_sub;
21 public SendMail(string to, string body, string sub)
22 {
23 tb_to = to.Trim();
24 tb_body = body.Trim();
25 tb_sub = sub.Trim();
26 }
27
28 public void sengmill_net()
29 {
30 tb_from = "xxxx@21cn.com";
31 tb_mailBody = tb_body;
32 tb_smtpserver = "smtp.21cn.com";
33 System.Web.Mail.MailMessage mailmsg = new System.Web.Mail.MailMessage();
34 mailmsg.From = tb_from;
35 mailmsg.To = tb_to;
36 mailmsg.Body = tb_mailBody;
37 mailmsg.Subject = tb_sub;
38 mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
39 //是否需要验证,一般是要的
40 mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "xxxxx");
41 //自己邮箱的用户名
42 mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "xxxxx");
43 //自己邮箱的密码
44 System.Web.Mail.SmtpMail.SmtpServer = tb_smtpserver;
45 System.Web.Mail.SmtpMail.Send(mailmsg);
46 }
47}
48
49public partial class bank : System.Web.UI.Page
50{
51 protected void Page_Load(object sender, EventArgs e)
52 {
53
54 }
55 protected void btnSend_Click(object sender, EventArgs e)
56
57 {
58 ////调用代码
59 SendMail t=new SendMail(xxx@xxx.com,"文本内容","标题内容");
60 t.sengmill_net();
61 }
62}
做自己的想做的事情,让别人去想把。