1
<system.net>
2
<mailSettings>
3
<smtp from="Emailname">
4
<network host="smtp.163.com" userName="Emailname" password="Emailpassword"
5
port="25" defaultCredentials="false"/>
6
</smtp>
7
</mailSettings>
8
</system.net>
2
3
4
5
6
7
8
二、然后编写发送邮件的函数:
1
Asp.net 自动发送邮件的方法
2
今天有一个模块需要自动发送邮件的功能,就随便写了一个,记录一下作为积累。
3
4
5
一、首先需要配置web.config文件:
6
7
8
<system.net>
9
<mailSettings>
10
<smtp from="Emailname">
11
<network host="smtp.163.com" userName="Emailname" password="Emailpassword"
12
port="25" defaultCredentials="false"/>
13
</smtp>
14
</mailSettings>
15
</system.net>
16
17
18
二、然后编写发送邮件的函数:
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
三、最后就是对函数的调用了:
1
//自动发送邮件
2
string mailSubject = "会员注册确认函";
3
string mailBody = "正文内容。";
4
string mailFrom = ConfigurationManager.AppSettings["SendMail"];
5
ArrayList List = new ArrayList();
6
List.Add(Server.MapPath(ConfigurationManager.AppSettings["SendMailText"]));
7
if (MySendMail(this.txtEmail.Text, mailSubject, mailBody, mailFrom, List))
8
}
2
3
4
5
6
7
8