Decode it using System.Convert and use MailBuilder.AddAttachment overload that takes byte array to create an attachment, which is going to be added to the email you are creating.
const string base64 = "SGVsbG8=";
byte[] data = Convert.FromBase64String(base64);
MailBuilder builder = new MailBuilder();
builder.From.Add(new MailBox("alice@example.com"));
builder.To.Add(new MailBox("bob@example.com"));
builder.Text = "See attached file.";
builder.Subject = "Attachment";
MimeData attachment = builder.AddAttachment(data);
attachment.FileName = "report.dat";
IMail email = builder.Create();
[Edit]
Here's the code to create valid message with detached signature:
MimeFactory f = new MimeFactory();
MimeMixed root = f.CreateMimeMixed(f.CreateMimeText("text"));
root.ContentType = ContentType.MultipartSigned;
MimePkcs7Signature signature =
f.CreatePkcs7Signature(Convert.FromBase64String(@"MIIE....=="));
signature.ContentType = ContentType.ApplicationPkcs7Signature;
root.Parts.Add(signature);
MimeDocument document = new MimeDocumentFactory().CreateMimeDocument(root);
IMail mail = new MailBuilder().CreateFromDocument(document);
mail.From.Add(new MailBox("email@in-the-certificate.com"));
Following code checks, if the parsed message has valid signature:
new MailBuilder().CreateFromEml(mail.Render()).CheckSignature(true);
You should probably add additional Content-Type parameters, such as protocol and micalg:
Content-Type: multipart/signed;
protocol="application/pkcs7-signature";
micalg=SHA1;
Again - This is not correct way of doing this. You should use MailBuilder.Sign method:
https://www.limilabs.com/blog/send-signed-email-using-smime
https://www.limilabs.com/blog/send-signed-email-smime-sha-512