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>
"
);
}
}
查看全文
相关阅读:
DelphiXE下的字符串变化
FastMM配置文件详解
[转] FastMM、FastCode、FastMove的使用
FastMM 定位内存泄露的代码位置
转 Delphi中使用FastMM4结合View CPU避免内存泄漏
[转] FastMM使用详解
salesforce 零基础开发入门学习(九)Approval Process 介绍
salesforce 零基础开发入门学习(八)数据分页简单制作
salesforce 零基础开发入门学习(七)PickList的value值获取
salesforce 零基础开发入门学习(六)简单的数据增删改查页面的构建
原文地址:https://www.cnblogs.com/wdx2008/p/994275.html
最新文章
Word中批量替换软回车
转 : 用Delphi编写安装程序
学习 Message(5): 关于 TApplicationEvents.OnMessage 的第二个参数 可以屏蔽 TWebBrowser右键菜单:
[转万一] 不使用标题栏拖动窗体
创建com服务器
时间格式设置
Delphi中Messagedlg用法
转:ExpressBars中的停靠控件使用
delphi 中TStringList Clear 方法的时候该对象有没有被释放
Delphi 包的设计思想及它与PAS、BPL、DCU、DLL、OXC的关系。
热门文章
Dev 控件问题多少
virtualtree 的使用(Delphi)
delphi中VirtualStringTree树使用方法之终结篇!
Delphi Virtual String Tree 基本用法
转 Delphi Invalidate的用法
Delphi 2009 泛型容器单元(Generics.Collections)[1]: TList<T>
泛型容器单元(Generics.Collections)[3]: TStack<T> 堆栈列表
泛型容器单元(Generics.Collections)[2]: TQueue<T> 队列列表
TStringList 常用操作
利用StringList对象来管理这些动态生成的对象
Copyright © 2011-2022 走看看