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
}
查看全文
相关阅读:
JSP基础学习(二)
JSP基础学习(一)
Android 使用开源xUtils来实现多线程下载(非原创)
Android 多线程断点下载(非原创)
Android HttpClient框架get和post方式提交数据(非原创)
Android ListView使用(非原创)
ScrollView 的使用(非原创)
Android SQLite API的使用(非原创)
Android SQLite的使用2(非原创)
位运算
原文地址:https://www.cnblogs.com/nasa/p/680434.html
最新文章
unblock with 'mysqladmin flush-hosts'"
authconfig-tui
64位机器源码安装之configure
quick-cocos2d-x-develop资源打包环境安装
shell数组
nginx导流进行服务更新流程
反向代理服务器的工作原理(转)
GraphicsMagick+IM4Java在项目中的使用总结
使用java处理大文件
经历与价值(刘学愚)
热门文章
集合类
面试相关
项目实践
MQ基本知识
常用设计模式学笔
网络编程
docker镜像制作
Spring基础知识
运维监控工具
分布式事务
Copyright © 2011-2022 走看看