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
查看全文
相关阅读:
用cdsview创建objectpage
Promise的一个小例子
使用CDSVIew创建List Report
abap各种常用功能
新建cdsview时的几个注解说明
使用ABAP CDS views创建一个分析模型并设置参数
使用ABAP CDS views 创建一个分析模型
sapui5 walkthrough 26-30
sapui5 walkthrough 21-25
T-code 大全
原文地址:https://www.cnblogs.com/goldnet/p/1515310.html
最新文章
linux 与 window 对比式理解与应用
2015年Java开发岗位面试题归类
六大步骤分解产品原型设计过程
MySQL:IP 地址转换(在常见IP地址现数字之间相互转换)
为什么“hbase.zookeeper.quorum”必须配奇数个数的DataNode
win7右键在桌面上转圈圈的解决办法
js 闭包
工作流引擎
ip反查域名
JSP转译成Servlet详细过程
热门文章
小数位 处理函数
BAPI_ACC_DOCUMENT_POST 字段增强
BAPI_ACC_DOCUMENT_POST 字段增强
ALV SPLITTER 分割器 需要在屏幕上画个控件
OLE 一些常用的处理
高级 DO 语法
远程调用程序FORM (增强会用到)
SAP SM开头的 TCODE
PO CREATE
Fiori程序的作成前言
Copyright © 2011-2022 走看看