C # Create a MIME message?

Is there any built-in functionality for a MIME file in C # .Net? I want to do the following:

  • Convert file to MIME message
  • Sign MIME message in pcks 7 blob
  • MIME that pkcs 7 blob
  • Finally, encrypt everything.

Any suggestions on how I will do this (not for encryption or signing, other than MIMEing)? What exactly is associated with a MIMEing file?

+3
source share
3 answers

There is a good commercial package for a small fee: Mime4Net

+2
source

, , .NET. Attachment; .NET 2.

+2

As far as I know, there is no such support in bare .NET. You should try one of the third-party libraries. One of them is Rebex Secure Mail for .NET . The following code shows how to achieve it:

using Rebex.Mail;
using Rebex.Mime.Headers;
using Rebex.Security.Certificates;
...

// load the sender certificate and 
// associated private key from a file 
Certificate signer = Certificate.LoadPfx("hugo.pfx", "password");

// load the recipient certificate 
Certificate recipient = Certificate.LoadDer("joe.cer");

// create an instance of MailMessage 
MailMessage message = new MailMessage();

// set its properties to desired values 
message.From = "hugo@example.com";
message.To = "joe@example.com";
message.Subject = "This is a simple message";
message.BodyText = "Hello, Joe!";
message.BodyHtml = "Hello, <b>Joe</b>!";

// sign the message using Hugo certificate 
message.Sign(signer);

// and encrypt it using Joe 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) 

(Code taken from the S / MIME training page )

+2
source

Source: https://habr.com/ru/post/1755029/


All Articles