Current solution is:
1.create msg file using MsgKit Nuget package.
2.Applying sensitivity label using Microsoft information protection SDK to the msg file created.
3.Read from, to, subject, body and attachment info from encrypted email message and pass this to send grid API to send email.
4.This is working fine when email body is plain text.
5.Problem occurs when email body contains html content, cannot view the contents of the received email.
We reached out to MIP support team, they figured out it is due to incorrect msg file created by MsgKit when email body is html content. But not sure exactly what is going wrong with msg file.
Please let us know you need any more information to investigate this issue.
below is the sample code of how msg file is being created.
public class CompoundFileHandler : ICompoundFileHandler
{
public System.IO.Stream CreateMsgFile(ProtectedEmailMessage message)
{
var sender = new Sender(message.From.Address, message.From.Name);
using var email = new Email(sender, message.Subject);
if (message.BodyType == BodyType.Text)
{
email.BodyText = message.Body;
}
else
{
email.BodyHtml = message.Body;
}
foreach (var to in message.Recipients)
{
email.Recipients.AddTo(to.Address, to.Name);
}
foreach (var cc in message.RecipientsCopy)
{
email.Recipients.AddCc(cc.Address,cc.Name);
}
foreach (var bcc in message.RecipientsBlindCopy)
{
email.Recipients.AddBcc(bcc.Address, bcc.Name);
}
foreach (var attachment in message.Attachments ?? Enumerable.Empty<LoadedAttachment>())
{
email.Attachments.Add(attachment.Stream, attachment.Name,isInline:attachment.IsInline, contentId: attachment.Id.ToString());
}
var result = new MemoryStream();
email.Save(result);
result.Seek(0, SeekOrigin.Begin);
return result;
}
Current solution is: 1.create msg file using MsgKit Nuget package. 2.Applying sensitivity label using Microsoft information protection SDK to the msg file created. 3.Read from, to, subject, body and attachment info from encrypted email message and pass this to send grid API to send email. 4.This is working fine when email body is plain text. 5.Problem occurs when email body contains html content, cannot view the contents of the received email.
We reached out to MIP support team, they figured out it is due to incorrect msg file created by MsgKit when email body is html content. But not sure exactly what is going wrong with msg file.
Please let us know you need any more information to investigate this issue.
below is the sample code of how msg file is being created.
public class CompoundFileHandler : ICompoundFileHandler { public System.IO.Stream CreateMsgFile(ProtectedEmailMessage message) { var sender = new Sender(message.From.Address, message.From.Name); using var email = new Email(sender, message.Subject); if (message.BodyType == BodyType.Text) { email.BodyText = message.Body; } else { email.BodyHtml = message.Body; }