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
}
查看全文
相关阅读:
NIST SIEM IR RISK
Django 部署时得到 Bad Request (400)(DEBUG = False)
MongoDB入门-插入文档
MongoDB入门-MongoDB的基本操作
MongoDB入门-Windows操作系统中将Mongodb设置为系统服务
MongoDB入门-Windows操作系统中Mongodb数据库的安装部署
Nginx反向代理功能-实现动静分离
Nginx反向代理功能-使用upstream指令反向代理多台web服务器案例
Nginx反向代理功能-添加头部报文信息
Nginx反向代理功能-缓存功能
原文地址:https://www.cnblogs.com/nasa/p/680434.html
最新文章
koa2中间件koa和koa-compose源码分析原理(一)
理解koa2 之 async + await + promise
理解 vue-router的beforeEach无限循环的问题
理解JSON Web Token (一)
express+vue+mongodb+session 实现注册登录
理解使用before,after伪类实现小三角形气泡框
js动态改变css伪类样式
深入理解mongodb查询条件语句
webpack4+node合并资源请求, 实现combo功能(二十三)
在NodeJS中操作文件常见的API
热门文章
Go语言之进阶篇Socket编程
go语言之进阶篇网络编程
go语言之进阶篇 select实现的超时机制
go语言之进阶篇通过select实现斐波那契数列
go语言之进阶篇Ticker的使用
go语言之进阶篇定时器重置
go语言之进阶篇定时器停止
go语言之进阶篇定时器Timer的使用
go语言之进阶篇单向channel的应用 (生产者,消费者模型)
go语言之进阶篇单向channel特点
Copyright © 2011-2022 走看看