Encodes the value of the specified header.
A string containing the encoded value of the header.
| Exception Type | Condition |
|---|---|
| MailBeeInvalidArgumentException | headerName or headerValue or targetEncoding is a null reference (Nothing in Visual Basic). |
This sample encodes Subject header into UTF-8 (Quoted-Printable version) and save the message into a file.
[C#] // 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");
[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 Dim msg As New MailMessage msg.Subject = MailMessage.GetEncodedHeaderValue("Subject", "Any text here", Encoding.UTF8, HeaderEncodingOptions.ForceEncoding Or HeaderEncodingOptions.Base64) msg.SaveMessage("C:\Temp\msg.eml")
MailMessage Class | MailBee.Mime Namespace | HeaderEncodingOptions