You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For a project that uses this, we build MailMessages and then send them out before logging them. For security, we need to replace a piece of text in the body with a useless string. The problem we faced is that the body parts were all MimePart, not the expected TextParts.
Our mail handler can accept a MailMessage which is converted using MimeMessage.CreateFromMailMessage, but when we go to work with the MimeMessage object in our logger, it only contains MimeParts under message.BodyParts (and likewise if we traverse the tree through message.Body).
The solution we found was to write the MimeMessage to a stream and then load a new object from the stream. This yields the expected TextParts that we are able to modify.
The text was updated successfully, but these errors were encountered:
For a project that uses this, we build MailMessages and then send them out before logging them. For security, we need to replace a piece of text in the body with a useless string. The problem we faced is that the body parts were all MimePart, not the expected
TextParts
.Our mail handler can accept a MailMessage which is converted using
MimeMessage.CreateFromMailMessage
, but when we go to work with the MimeMessage object in our logger, it only contains MimeParts under message.BodyParts (and likewise if we traverse the tree through message.Body).The solution we found was to write the MimeMessage to a stream and then load a new object from the stream. This yields the expected TextParts that we are able to modify.
The text was updated successfully, but these errors were encountered: