在C#.Net中是否有任何内置函数来MIME文件?我所希望做的是:C#创建MIME消息?
- 将文件转换成一个MIME消息
- 注册的MIME信息的PCKS 7 BLOB
- MIME是PKCS 7 BLOB
- 最后加密整个事情。
关于如何去解决这个问题(而不是加密或签名部分,但MIMEing)的任何建议?包含在MIMEing文件中的究竟是什么?
在C#.Net中是否有任何内置函数来MIME文件?我所希望做的是:C#创建MIME消息?
关于如何去解决这个问题(而不是加密或签名部分,但MIMEing)的任何建议?包含在MIMEing文件中的究竟是什么?
有一个很好的商业包装一小笔费用: Mime4Net
而不是处理第三方库,我建议你看看核心.NET库。使用Attachment类;它一直在.NET 2以上。
据我所知,没有这样的支持在裸露的.NET。你必须尝试一个第三方库。其中之一是我们的Rebex Secure Mail for .NET。下面的代码演示如何实现它:
using Rebex.Mail;
using Rebex.Mime.Headers;
using Rebex.Security.Certificates;
...
// load the sender's certificate and
// associated private key from a file
Certificate signer = Certificate.LoadPfx("hugo.pfx", "password");
// load the recipient's certificate
Certificate recipient = Certificate.LoadDer("joe.cer");
// create an instance of MailMessage
MailMessage message = new MailMessage();
// set its properties to desired values
message.From = "[email protected]";
message.To = "[email protected]";
message.Subject = "This is a simple message";
message.BodyText = "Hello, Joe!";
message.BodyHtml = "Hello, <b>Joe</b>!";
// sign the message using Hugo's certificate
message.Sign(signer);
// and encrypt it using Joe's certificate
message.Encrypt(recipient);
// if you wanted Hugo to be able to read the message later as well,
// you can encrypt it for Hugo as well instead - comment out the previous
// encrypt and uncomment this one:
// message.Encrypt(recipient, signer)
(从S/MIME tutorial page采取代号)如果皮蒂接受这个答案,我会奖励赏金。我的猜测是商业包装不会是我们想要的,但我不会为Petey说话。就我个人而言,我会走这条路去获得我认为有用的东西。 – Tergiver 2010-07-26 22:36:55
我最终编写了自己的MIME解析器。但我会接受这一点。 – 2010-07-27 14:46:05
“小”IFF你不想要来源。 – jeff7091 2013-10-11 06:05:26