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
}
查看全文
相关阅读:
模拟光照中的凹凸纹理原理和应用
Visual Studio 2010 SP1正式开放下载
同桌的你网工版
[转载]同桌的你程序员版
学习计划:SSIS
基于Java的HTML解析器
初次使用NHibernate遇到的问题
.NET下开源CMS系统汇总
MyEclipse、Tomcat启动项目报错
VBA 分文件夹 分excel
原文地址:https://www.cnblogs.com/nasa/p/680434.html
最新文章
Android中HandlerThread类的解释
VIM 用法
数据结构基本知识
C# xml 转 list 对象
net 6 用HttpClient发送XML PostAsync
C# 中如何输出双引号(转义字符的使用)
vuecli3升级到vuecli4
node.js16.13.0版本 对应nodesass sassloader 可行版本号
npm 配置默认安装包路径
Navicat for mysql远程连接数据库详(1130错误解决方法)
热门文章
flutter 国内镜像源列表
项目打包时出现了这种问题,是一个叫corejs的包出了问题;
vscode RemoteSSH 插件一直重复输入密码解决
安装k8s
filebeat 进程莫名消失
Ogre源代码浅析——脚本及其解析(八)
Ogre源代码浅析——脚本及其解析(七)
Ogre源代码浅析——Mesh文件结构及加载(二)
Ogre源代码浅析——Mesh文件结构及加载(一)
Ogre源代码浅析——Mesh文件结构及加载(三)
Copyright © 2011-2022 走看看