zoukankan
html css js c++ java
ASP.NET邮件外发
string
myemail
=
TextBox1.Text;
string
euser
=
TextBox2.Text;
string
pass
=
TextBox3.Text;
string
emailTo
=
TextBox4.Text;
string
title
=
TextBox5.Text;
string
semail
=
RadioButtonList1.SelectedValue.ToString();
string
smtp
=
TextBox6.Text;
if
(semail
==
"
1
"
)
{
MailMessage mailMsg
=
new
MailMessage();
//
设置正文格式
mailMsg.BodyFormat
=
MailFormat.Html;
//
设置收件人的邮件地址
mailMsg.To
=
emailTo;
//
设置发送者的邮件地址
mailMsg.From
=
myemail;
//
设置邮件主题
mailMsg.Subject
=
title;
//
设置邮件内容
mailMsg.Body
=
"
test
"
;
//
设置支持服务器验证
mailMsg.Fields.Add(
"
http://schemas.microsoft.com/cdo/configuration/smtpauthenticate
"
,
"
1
"
);
//
设置用户名
mailMsg.Fields.Add(
"
http://schemas.microsoft.com/cdo/configuration/sendusername
"
, euser);
//
设置用户密码
mailMsg.Fields.Add(
"
http://schemas.microsoft.com/cdo/configuration/sendpassword
"
, pass);
try
{
//
设置发送邮件服务器
SmtpMail.SmtpServer
=
smtp;
//
发送邮件
SmtpMail.Send(mailMsg);
Response.Write(
"
<script>alert('System.Web.Mail方法发信成功,请注意查收!');</script>
"
);
}
catch
(Exception err)
{
Response.Write(
"
System.Web.Mail方法发信失败!
"
+
err.Message.ToString());
}
}
else
{
jmail.Message Jmail
=
new
jmail.Message();
DateTime t
=
DateTime.Now;
String Subject
=
title;
String body
=
"
test
"
;
String FromEmail
=
myemail;
String ToEmail
=
emailTo;
//
Silent属性:如果设置为true,JMail不会抛出例外错误. JMail. Send( () 会根据操作结果返回true或false
Jmail.Silent
=
true
;
//
Jmail创建的日志,前提loging属性设置为true
Jmail.Logging
=
true
;
//
字符集,缺省为"US-ASCII"
Jmail.Charset
=
"
GB2312
"
;
//
信件的contentype. 缺省是"text/plain") : 字符串如果你以HTML格式发送邮件, 改为"text/html"即可。
Jmail.ContentType
=
"
text/html
"
;
//
添加收件人
Jmail.AddRecipient(ToEmail,
""
,
""
);
Jmail.From
=
FromEmail;
//
发件人邮件用户名
Jmail.MailServerUserName
=
euser;
//
发件人邮件密码
Jmail.MailServerPassWord
=
pass;
//
设置邮件标题
Jmail.Subject
=
Subject;
//
邮件添加附件,(多附件的话,可以再加一条Jmail.AddAttachment( "c:\\test.jpg",true,null);)就可以搞定了。[注]:加了附件,讲把上面的Jmail.ContentType="text/html";删掉。否则会在邮件里出现乱码。
//
Jmail.AddAttachment("c:\\test.jpg", true, null);
//
邮件内容
Jmail.Body
=
"
test
"
;
//
Jmail发送的方法
Jmail.Send(smtp,
false
);
Jmail.Close();
if
(Jmail.Send(smtp,
false
)
==
true
)
{
Response.Write(
"
<script>alert('Jmail方法发信成功,请注意查收!');</script>
"
);
}
else
{
Response.Write(
"
<script>alert('Jmail方法发信失败!');</script>
"
);
}
}
查看全文
相关阅读:
线段树的一种简化实现[原] by 踏雪赤兔
C 语言qsort 函数详解
【转载】Amit’s A star Page 中译文
Poj3468 线段树 成段更新
在VMware的CentOS中运行Cadence IC 615的怪现象
安装非认证的chrome插件和设置文件夹的权限
[模拟IC]基础知识1
如何删除 Windows.old 文件夹?
美国签证面签经历
三个不同属性的GTD工具
原文地址:https://www.cnblogs.com/wdx2008/p/994275.html
最新文章
HTTP协议头详解
转:spanner,Google全球分布式系统
事件与委托
转:机制与策略
【面试题】在二元树中找出和为某一值的所有路径
【转载】段错误总结(segmentation fault)
GCC使用入门【工具篇】
STL中list用法详解
【面试题】求用1,2,5这三个数不同个数组合的和为100的组合个数
memmove函数使用时注意的问题
热门文章
STL中map用法详解
posix_memalign详细解释
GDB调试程序【工具篇】
vi替换命令
Poj 3667 Hotel 线段树区间合并
hdoj 2653 Waiting ten thousand years for Love
Hdoj 1509 Windows Message Queue 优先队列最小堆实现
STL MAP 详解 (zz)
HDOJ1540 Tunnel Warfare 线段树区间合并
USACO 2.3.1 Longest Prefix Trie
Copyright © 2011-2022 走看看