MailMessageGetEncodedHeaderValue Method |
Encodes the value of the specified header.
Namespace: MailBee.MimeAssembly: 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
)
Public Shared Function GetEncodedHeaderValue (
headerName As String,
headerValue As String,
targetEncoding As Encoding,
options As HeaderEncodingOptions
) As String
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:
StringA string containing the encoded value of the header.
Exceptions Examples This sample encodes Subject header into UTF-8 (Quoted-Printable version) and save the message into a file.
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");
' 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")
See Also