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
}
查看全文
相关阅读:
第一课 进阶高手的大门
Codeforces Round #363 (Div. 2) C. Vacations
HDU 5718 Oracle
A
Fibonacci数的后9位
UESTC 982质因子分解
UESTC149 解救小Q
UESTC93 King's Sanctuary
HDU 4857 逃生
L1-006. 连续因子
原文地址:https://www.cnblogs.com/nasa/p/680434.html
最新文章
BZOJ3569 DZY Loves Chinese II
提高 Linux 上 socket 性能
Linux下性能监控工具介绍
linux下top命令参数解释
Linux操作系统下IPTables配置方法详解
mysql双机热备份的实现步骤
选择设置好ext3日志模式
高效配置Linux代理服务器 Squid介绍
Fast Scatter-Gather I/O
Oracle 系统表大全
热门文章
tcpdump/HTTP协议实践
第十课 C++异常简介
第九课 智能指针
第八课 泛型编程简介
第七课 课程学习小问答
第六课 算法效率的度量
第五课 算法的时间复杂度
第四课 程序灵魂的审判
第三课 初识程序的灵魂
第二课 数据的艺术
Copyright © 2011-2022 走看看