zoukankan
html css js c++ java
.net 发送邮件
Code
1
2
/**/
///
<summary>
3
///
发送邮件(多个人以,分开)
4
///
</summary>
5
///
<param name="from">
发件人
</param>
6
///
<param name="to">
收件人
</param>
7
///
<param name="title">
标题/主题
</param>
8
///
<param name="content">
信件内容
</param>
9
///
<param name="cc">
抄送人
</param>
10
///
<param name="sFileName">
文件名称
</param>
11
///
<returns></returns>
12
public
static
string
SendMail(
string
from,
string
to,
string
title,
string
content,
string
cc,
string
sFileName)
13
{
14
HttpContext context
=
HttpContext.Current;
15
string
sMsg
=
""
;
16
try
17
{
18
string
sPath
=
Global.UTDocPath
+
"
Email/
"
;
19
SmtpClient smtp
=
new
SmtpClient(
"
testEmail
"
);
20
smtp.UseDefaultCredentials
=
true
;
21
smtp.DeliveryMethod
=
SmtpDeliveryMethod.Network;
22
MailMessage msg
=
new
MailMessage(from, to, title, content);
23
if
(sFileName
!=
""
)
24
{
25
string
[] sfile
=
sFileName.Split(
new
char
[]
{
'
,
'
}
);
26
for
(
int
i
=
0
; i
<
sfile.GetLength(
0
); i
++
)
27
{
28
if
(sfile[i].Trim()
!=
""
)
29
{
30
System.Net.Mail.Attachment attachment
=
new
System.Net.Mail.Attachment(context.Server.MapPath(sPath
+
"
/
"
+
sfile[i].Trim()));
31
msg.Attachments.Add(attachment);
32
}
33
}
34
35
}
36
37
msg.BodyEncoding
=
System.Text.Encoding.UTF8;
38
msg.SubjectEncoding
=
System.Text.Encoding.UTF8;
39
if
(cc
!=
""
)
40
msg.CC.Add(cc);
41
msg.IsBodyHtml
=
true
;
42
smtp.Send(msg);
43
sMsg
=
"
发送成功
"
;
44
}
45
catch
(System.Net.Mail.SmtpException ex)
46
{
47
sMsg
=
ex.Message.ToString();
48
}
49
return
sMsg;
50
}
51
查看全文
相关阅读:
MD5 初探。
VFW程序分析
IE版本简单兼容 JS闭包和JS对象解说。
句柄和指针
超时时间已到。在从池中获取连接之前超时时间已过。出现这种情况可能是因为所有池连接都已被使用并已达到最大池大小
DataGrid模板列上的ImageButton 不能触发ItemCommand事件
html转换成文本
几种取数据库随机记录的方法
打开.net时CPU占用率100%的问题个人处理办法
强制输出wxl
原文地址:https://www.cnblogs.com/goldnet/p/1515310.html
最新文章
详细讲解jquery带进度上传插件Uploadify(ASP.NET版本)使用
Windows Service结合调试+相关资料 之我见
JQ error 异常错误
属性(Properties)和字段在C#中的关系
T_SQL case 语法定义
Uploadify的一些参数
VFW实例程序。简单 “视频捕获”,没有压缩、线程、保存、等更多的功能
ServiceProcessInstaller 类
System.Configuration.Install 命名空间
System.ServiceProcess 命名空间
热门文章
揭开Socket编程的面纱 (三)
VFW技术资料基本解析。
Socket握手通信实例++++++++图
VFW 结构 综合
ServiceInstaller 类
用 VS2008 打开 VS2010 的解决方案文件
JQ AJAX 超时问题 timeout
修改 计算机名后,修改SQLserver 注册服务器对象的名称
VFW基础细节
转 Web service是什么?
Copyright © 2011-2022 走看看