+1 vote
by (180 points)


We're using 2013R2.

For one particular email we are trying to update the BodyHtml field of the MailMessage class and we get the following stack trace:

--- Start Exception Stack ---
Rebex.Mail.MailException: Cannot change read-only message.
at Rebex.Mail.AttachmentBase.SetContent(String text, String mediaType)
at Rebex.Mail.MailMessage.set_BodyHtml(String value)
at pf.MCC.Server.Common.Models.RebexEmail.ConvertCidToEmbedded()
at pf.MCC.Server.Common.Models.RebexEmail.Load(Stream stream, String id)
at pf.MCC.Server.Common.Models.Store.SaveNewMediaItem(NewMailMessage newMailMessage)
--- End Exception Stack ---

Normally there is no issue... just this one email. How does this property get into the read-only state and is there anyway to override it?

A bit more information. It appears there are some kind of issues with the signature. The message when trying to open the email in Exchange is: The signature is invalid because you have either distrusted or not yet chosen to trust the following Certificate Authority".

Applies to: Rebex Secure Mail

1 Answer

+1 vote
by (58.9k points)


this exception is thrown when you are trying to set the BodyHtml of a signed MailMesssage. In order to change the BodyHtml of a signed message, you would have to first remove the signature like this:

MailMessage mail = new MailMessage();

if (mail.IsSigned)

mail.BodyHtml = "HTML body";

Moreover, with encrypted messages (mail.IsEncrypted = 'true') the BodyHtml also cannot be set directly. So you would have to use the Decrypt method first to be able to set the BodyHtml.

by (180 points)

Perfect. Thank you.