MailMessageEncodeAllHeaders Method
Encodes all message headers into the specified encoding.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax
public void EncodeAllHeaders(
	Encoding targetEncoding,
	HeaderEncodingOptions options
)

Parameters

targetEncoding
Type: System.TextEncoding
The charset which is used to encode the value of the specified header.
options
Type: MailBee.MimeHeaderEncodingOptions
The additional options which affect how the message headers are encoded.
Exceptions
ExceptionCondition
MailBeeInvalidArgumentExceptiontargetEncoding is a null reference (Nothing in Visual Basic).
Remarks

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(String, String, Encoding, HeaderEncodingOptions) method.

Examples
This sample loads the message from .EML file, encodes it, and saves this message to disk.
// 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");
See Also