MailMessageGetEncodedHeaderValue Method
Encodes the value of the specified header.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax
public static string GetEncodedHeaderValue(
	string headerName,
	string headerValue,
	Encoding targetEncoding,
	HeaderEncodingOptions options
)

Parameters

headerName
Type: SystemString
The name of the header.
headerValue
Type: SystemString
The value of the header.
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 header is encoded.

Return Value

Type: String
A string containing the encoded value of the header.
Exceptions
ExceptionCondition
MailBeeInvalidArgumentExceptionheaderName or headerValue or targetEncoding is a null reference (Nothing in Visual Basic).
Examples
This sample encodes Subject header into UTF-8 (Quoted-Printable version) and save the message into a file.
// To use the code below, import the following namespaces at the top of your code.
using System.Text;
using MailBee;
using MailBee.Mime;

MailMessage msg = new MailMessage();
msg.Subject = MailMessage.GetEncodedHeaderValue("Subject", "Any text here", Encoding.UTF8, HeaderEncodingOptions.ForceEncoding | HeaderEncodingOptions.Base64);
msg.SaveMessage(@"C:\Temp\msg.eml");
See Also