Encodes all message headers into the specified encoding.
The developer should use this method before saving or sending an e-mail message if any message headers or attachment names contain international characters.
The developer can also encode custom header names using GetEncodedHeaderValue method.
| Exception Type | Condition |
|---|---|
| MailBeeInvalidArgumentException | targetEncoding is a null reference (Nothing in Visual Basic). |
This sample loads the message from .EML file, encodes it, and saves this message to disk.
[C#] // To use the code below, import the following namespaces at the top of your code. using System.Text; using MailBee; using MailBee.Mime; // The actual code (put it into a method of your class). MailMessage msg = new MailMessage(); msg.LoadMessage(@"C:\Docs\source.eml"); msg.EncodeAllHeaders(Encoding.UTF8, HeaderEncodingOptions.Base64); msg.SaveMessage(@"C:\Temp\result.eml");
[Visual Basic] ' To use the code below, import the following namespaces at the top of your code. Imports System.Text Imports MailBee Imports MailBee.Mime ' The actual code (put it into a method of your class). Dim msg As New MailMessage msg.LoadMessage("C:\Docs\source.eml") msg.EncodeAllHeaders(Encoding.UTF8, HeaderEncodingOptions.Base64) msg.SaveMessage("C:\Temp\result.eml")
MailMessage Class | MailBee.Mime Namespace | HeaderEncodingOptions