ToUTF8 Method

Returns source string converted in UTF-8 format.

UTF-8 format is used to represent international characters in e-mail. It is especially useful when a e-mail is written in several languages.

Note that in most cases you won't need to use this method directly as MailBee by default encodes e-mails being composed in UTF-8. The typical case of using this method is when you need to output the data you received from an existing e-mail onto web page in UTF-8 format.

strUTF8 = ObjectName.ToUTF8(Src, [SrcCharset])  
Src As String Source text string (if SrcCharset parameter is omitted, this string must be in Unicode format)  
SrcCharset As String (optional) Charset (such as "us-ascii", "iso-8859-1", "gb2312", etc.) used to compose Src. If omitted, default ANSI codepage of the machine is assumed  
Return value As String UTF-8 version of the source  

Usage example:

Dim Mailer, strUTF8, strUnicodeSubject, strUnicodeBody

' Assume strUnicodeSubject and strUnicodeBody already contain some unicode text
strUnicodeSubject = "some unicode chars here"
strUnicodeBody = "some unicode chars here"

'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 = "" If Mailer.Connect Then Mailer.Message.ToAddr = "" Mailer.Message.FromAddr = "" strUTF8 = Mailer.Message.ToUTF8(strUnicodeSubject) Mailer.Message.Subject = Mailer.Message.EncodeHeaderText("Subject", strUTF8, "utf-8", 3) Mailer.Message.BodyText = Mailer.Message.ToUTF8(strUnicodeBody) Mailer.Message.Charset = "utf-8" Mailer.Send Mailer.Disconnect End If

See Also:

Message Object
Charset Property
EncodeHeaderText Method

Copyright © 2002-2022, AfterLogic Corporation. All rights reserved.