Send SMIME format emails using Microsoft Graph API C# SDK

442 views Asked by At

I am trying to send an email in SMIME format using Microsoft Graph API C# SDK

I have followed this link and I am able to send MIME type email https://gsexdev.blogspot.com/2021/08/sending-mimemessage-via-microsoft-graph.html

But if someone can provide a sample code for SMIME that will be helpful.

1

There are 1 answers

0
Glen Scales On

MimeKit supports SMIME encryption http://www.mimekit.net/docs/html/Working-With-SMime.htm so you can take the Message object in that example encrypt or sign it then use the same method of getting the raw content to send via

        var stream = new MemoryStream();
        message.WriteTo(stream);
        
        stream.Position = 0;
        StringContent MessagePost = new StringContent(Convert.ToBase64String(stream.ToArray()),Encoding.UTF8, "text/plain");

What you can't do with the Graph API is get the existing SMIME certificate for a user if that exists in AAD you need to export it first and store it somewhere that your app can access if you want to use it.