EncodeHeaderText Method
Encodes specified text string to allow using
international characters (Japan, Korean, Russian, etc.) and very long header
lines.
By default, MailBee encodes all headers with international names (Message.AutoEncodeHeaders=True). You need this method only for advanced purposes, when automatic encoding is not an option.
A standard header string may not contain international characters. Header encoding eliminates the problem, and also splits headers to multiple lines to avoid very long lines.
This method does not change message headers. It just returns encoded string
you may assign to the message header value.
This method can also be used to encode attachment filenames (allows using international characters in attachment filenames).
Note: Some headers ("From", "To",
"CC") contain e-mail address (it MUST NOT be encoded). So you must
always properly set HeaderName so MailBee will use special encoding for
address-containing headers.
strEncodedString = ObjectName.EncodeHeaderText(HeaderName, HeaderText, Charset, Encoding) |
Parameters: | ||
HeaderName As String | Case-insensitive name of the header to encode (like "Subject", "From", "To", "name"). Can be empty. Use empty value when encoding attachment filenames (if the value is empty, wrapping at 76-th character will no occur). | |
HeaderText As String | Text to encode (header value) | |
Charset As String | Charset used for composing HeaderText (for example, "windows-1251" if HeaderText is written in Russian) | |
Encoding As Long | Specifies encoding to use. Only two
encoding schemes are applicable for header encoding: - Encoding = 2 - Quoted-Printable encoding - Encoding = 3 - Base64 encoding |
|
Return value As Boolean | On success, encoded value of HeaderText. On error, empty string. | |
Remarks: | You can also use this method to encode attachment filenames containing international characters. An example below shows this. |
Usage example:
Dim Mailer, strFilename 'Using visual basic to create object Set Mailer = CreateObject("MailBee.SMTP") 'Using ASP to create object 'Set Mailer = Server.CreateObject("MailBee.SMTP") 'In ASP use Response.Write instead of MsgBox Mailer.LicenseKey = "put your license key here" Mailer.ServerName = "mail.server.com" If Mailer.Connect Then Mailer.Message.ToAddr = "bill@yoursite.com" Mailer.Message.FromAddr = Mailer.EncodeHeaderText("From", "Алекс <alex@server.ru>", "windows-1251", 3) Mailer.Message.Subject = "Hello, There is word 'Alex' written in Russian in 'From' field" Mailer.Message.ImportBodyText "C:\docs\letter.htm", True strFilename = Mailer.Message.EncodeHeaderText("name", "long or international filename to encode.htm", "us-english", 2) Mailer.Message.AddAttachment "C:\docs\long or international filename to encode.htm",,, strFilename Mailer.Send Mailer.Disconnect End If
See Also:
AddAttachment
Method
BodyText Property
AltBodyText Property
Copyright © 2002-2024, AfterLogic Corporation. All rights reserved.