.net 随笔
记录你的轨迹
博客园
首页
社区
新随笔
联系
订阅
管理
随笔-20 评论-9 文章-0 trackbacks-0
使用 DotnetOpenMail发送带附件的邮件
DotNetOpenMail.EmailMessage email
=
new
DotNetOpenMail.EmailMessage();
email.FromAddress
=
new
DotNetOpenMail.EmailAddress(
"
zhifengwu1211@126.com
"
);
DotNetOpenMail.EmailAddressCollection toAddresses
=
new
DotNetOpenMail.EmailAddressCollection();
DotNetOpenMail.EmailAddress toAddress
=
new
DotNetOpenMail.EmailAddress(
"
zhifengwu1211@126.com
"
);
toAddresses.Add(toAddress);
email.ToAddresses.Add(toAddress);
email.Subject
=
"
this is test
"
;
DotNetOpenMail.SmtpServer smtpserver
=
new
DotNetOpenMail.SmtpServer(
"
192.168.2.129
"
);
StreamReader readfile
=
new
StreamReader(
"
d:\\mycert.cer
"
);
Byte[] fileBytes
=
System.Text.Encoding.Default.GetBytes(readfile.ReadToEnd());
DotNetOpenMail.FileAttachment fileAttachment
=
new
DotNetOpenMail.FileAttachment(fileBytes);
fileAttachment.FileName
=
"
mycert.cer
"
;
email.AddMixedAttachment(fileAttachment);
bool
result
=
email.Send(smtpserver);
if
(result
==
true
)
this
.label1.Text
=
"
success
"
;
else
this
.label1.Text
=
"
error
"
;
posted on 2007-01-25 21:37
冰封王座(.net)博客
阅读(363)
评论(2)
编辑
收藏
评论:
#1楼
2007-07-25 17:05 |
数据绑定者
我发的附件是乱码,我用 System.Text.Encoding.Default.GetBytes(readfile.ReadToEnd());
默认的编码,发送出去后还是乱码,怎么办啊
回复
引用
查看
#2楼
2008-05-06 15:57 |
冷火
emailMessage.HeaderEncoding = DotNetOpenMail.Encoding.EncodingType.Base64;
emailMessage.HeaderCharSet = Encoding.GetEncoding("gb2312");
emailMessage.TextPart.CharSet = Encoding.GetEncoding("gb2312");
emailMessage.TextPart.Encoding = DotNetOpenMail.Encoding.EncodingType.Base64;
回复
引用
查看
新用户注册
刷新评论列表
标题
姓名
主页
Email
(博主才能看到)
验证码
*
看不清,换一张
[
登录
][
注册
]
内容(请不要发表任何与政治相关的内容)
网站首页
新闻频道
社区
小组
博问
网摘
闪存
找找看
Remember Me?
登录
使用高级评论
新用户注册
返回页首
恢复上次提交
[使用Ctrl+Enter键可以直接提交]
相关文章:
Memcached使用点滴
使用 LINQ 进行数据转换
使用Visual Studio2005入门.Net2.0系列视频教程
ASP.NET AJAX入门系列(2):使用ScriptManager控件
CCTV使用微软卫星地图
索爱可能使用Android平台
remoting的使用
控件使用求助
插件使用分享交流
不能使用 2008 中的 Ajax
相关链接:
最新IT新闻:
Google股价跌破329美元 61%员工期权价值归零
十年祭:昔日明星软件今何在?
六大可能出售IT企业名单:SUN领头或被猎走
Linux内核2.6.27正式到来
《星际争霸2》一分为三 各种族依次登场
<
2007年1月
>
日
一
二
三
四
五
六
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
与我联系
发短消息
搜索
常用链接
我的随笔
我的空间
我的短信
我的评论
更多链接
我的参与
我的新闻
最新评论
我的标签
留言簿
(1)
给我留言
查看留言
随笔档案
2007年5月 (1)
2007年4月 (3)
2007年2月 (2)
2007年1月 (1)
2006年12月 (3)
2006年11月 (6)
2006年10月 (4)
文章分类
代码细节
框架设计
最新评论
阅读排行榜
1. 对比 javascript url编码(1129)
2. 在C#中使用 makecert 创建自签名的证书(831)
3. 创建带签名的cab包的完整流程(378)
4. Google SiteMap的作用及协议格式详解[转摘] (376)
5. 使用 DotnetOpenMail发送带附件的邮件(363)
评论排行榜
1. 在C#中使用 makecert 创建自签名的证书(3)
2. 使用 DotnetOpenMail发送带附件的邮件(2)
3. 有关 java 与 C#细节不同(1)
4. 对比 javascript url编码(1)
5. UML视图使用(1)