zoukankan
html css js c++ java
记录一个发邮件的cs文件
/**/
/*
---------------------------------
* E-mail 发送接口
* 调用示例
* ---------------------------------
*/
public
class
webMail
{
-- declare the variables --
#region
-- declare the variables --
private
string
_sender
=
""
;
private
string
_account
=
""
;
private
string
_password
=
""
;
private
string
_server
=
""
;
private
string
_subject
=
""
;
private
string
_body
=
""
;
private
string
_recv
=
""
;
#endregion
-- declare the interface --
#region
-- declare the interface --
public
string
sender
{
set
{
_sender
=
value;
}
}
public
string
sendAccount
{
set
{
_account
=
value;
}
}
public
string
sendPassword
{
set
{
_password
=
value;
}
}
public
string
sendServer
{
set
{
_server
=
value;
}
}
public
string
sendSubject
{
set
{
_subject
=
value;
}
}
public
string
sendBody
{
set
{
_body
=
value;
}
}
public
string
sendRecv
{
set
{
_recv
=
value;
}
}
#endregion
string sendMail()
#region
string sendMail()
public
string
sendMail()
{
try
{
MailMessage mailMessage
=
new
MailMessage();
mailMessage.Fields.Add(
"
http://schemas.microsoft.com/cdo/configuration/smtpauthenticate
"
,
"
1
"
);
mailMessage.Fields.Add(
"
http://schemas.microsoft.com/cdo/configuration/sendusername
"
, _account);
mailMessage.Fields.Add(
"
http://schemas.microsoft.com/cdo/configuration/sendpassword
"
, _password);
mailMessage.From
=
_sender;
mailMessage.To
=
_recv;
mailMessage.Subject
=
_subject;
mailMessage.Body
=
_body;
SmtpMail.SmtpServer
=
_server;
SmtpMail.Send(mailMessage);
return
"
1
"
;
}
catch
(Exception ex)
{
return
ex.Message.ToString();
}
}
#endregion
string testSend(string sender,string subject,string body,string recv)
#region
string testSend(string sender,string subject,string body,string recv)
public
string
testSend(
string
sender,
string
subject,
string
body,
string
recv)
{
try
{
MailMessage mailMessage
=
new
MailMessage();
mailMessage.Fields.Add(
"
http://schemas.microsoft.com/cdo/configuration/smtpauthenticate
"
,
"
1
"
);
mailMessage.Fields.Add(
"
http://schemas.microsoft.com/cdo/configuration/sendusername
"
,
"
kefu@huabaoTrust.com
"
);
mailMessage.Fields.Add(
"
http://schemas.microsoft.com/cdo/configuration/sendpassword
"
,
"
123456
"
);
mailMessage.From
=
sender;
mailMessage.To
=
recv;
mailMessage.Subject
=
subject;
mailMessage.Body
=
body;
SmtpMail.SmtpServer
=
"
www.huabaotrust.com
"
;
SmtpMail.Send(mailMessage);
return
"
1
"
;
}
catch
(Exception ex)
{
return
ex.Message.ToString();
}
}
#endregion
string sendMail(string sender,string subject,string body,string recv)
#region
string sendMail(string sender,string subject,string body,string recv)
public
string
sendMail(
string
sender,
string
subject,
string
body,
string
recv)
{
try
{
MailMessage mailMessage
=
new
MailMessage();
mailMessage.Fields.Add(
"
http://schemas.microsoft.com/cdo/configuration/smtpauthenticate
"
,
"
1
"
);
mailMessage.Fields.Add(
"
http://schemas.microsoft.com/cdo/configuration/sendusername
"
, _account);
mailMessage.Fields.Add(
"
http://schemas.microsoft.com/cdo/configuration/sendpassword
"
, _password);
mailMessage.From
=
sender;
mailMessage.To
=
recv;
mailMessage.Subject
=
subject;
mailMessage.Body
=
body;
SmtpMail.SmtpServer
=
_server;
SmtpMail.Send(mailMessage);
return
"
1
"
;
}
catch
(Exception ex)
{
return
ex.Message.ToString();
}
}
#endregion
string sendMail(string sender,string subject,string body,string recv,string server,string account,string password)
#region
string sendMail(string sender,string subject,string body,string recv,string server,string account,string password)
public
string
sendMail(
string
sender,
string
subject,
string
body,
string
recv,
string
server,
string
account,
string
password)
{
try
{
MailMessage mailMessage
=
new
MailMessage();
mailMessage.Fields.Add(
"
http://schemas.microsoft.com/cdo/configuration/smtpauthenticate
"
,
"
1
"
);
mailMessage.Fields.Add(
"
http://schemas.microsoft.com/cdo/configuration/sendusername
"
, account);
mailMessage.Fields.Add(
"
http://schemas.microsoft.com/cdo/configuration/sendpassword
"
, password);
mailMessage.From
=
sender;
mailMessage.To
=
recv;
mailMessage.Subject
=
subject;
mailMessage.Body
=
body;
SmtpMail.SmtpServer
=
server;
SmtpMail.Send(mailMessage);
return
"
1
"
;
}
catch
(Exception ex)
{
return
ex.Message.ToString();
}
}
#endregion
}
查看全文
相关阅读:
Java 语句总结
存储过程 替换字符串
解决MyEclipse吃内存以及卡死的方法
Tomcat启动时自动加载一个类
oracle sql日期比较:
项目数据库操作
Oracle 删除重复数据只留一条
oracle ORA-00001:违反唯一约束条件
Oracle ORA-12519: TNS:no appropriate service handler found 解决
tomecat 配置修改 及启动配置
原文地址:https://www.cnblogs.com/nasa/p/680434.html
最新文章
记账本小程序7天开发记录(第二天)
自学Linux命令的四种方法
Linux 命令 有关用户权限修改
数组指针和指针数组的区别
linux打包压缩命令汇总
Oracle建立表空间和用户
查询ORACLE所有表
LKM的概念
各种软件读netcdf
Linux查看文件编码格式及文件编码转换
热门文章
oracle 表空间维护
jQuery(5)——jQuery fade淡入淡出效果
jQuery(4)——jQuery hide、show方法的简单了解
jQuery(3)——jQuery键盘事件
jQuery(2)——jQuery鼠标事件
jQuery(1)——jQuery选择器
jQuery(0)——Dom对象和jQuery包装集
免费SSL证书申请
我也不知道这算不算bug了,单纯记录,没别的意思,图片是上传在慕课网的,所以预览不了。。0.0
julia体验——输出HelloWorld
Copyright © 2011-2022 走看看