ConvertCharset Method


Converts the supplied string encoded in the given charset into another charset.

When composing messages (with international characters), you may need this method to convert the data into the required charset encoding. In this case, you'll also need to specify Charset property to let the recipient know which encoding you used.

When reading messages (with international characters), you'll usually use Codepage and CodepageMode properties instead.


strConverted = ObjectName.ConvertCharset(Src, SrcCharset, DestCharset)
 
Parameters:  
Src As String The source string encoded in SrcCharset.  
SrcCharset As String The charset encoding of the source string. If an empty string, it will be assumed that Src is not encoded (i.e. it's Unicode).  
DestCharset As String The charset encoding of the output string. If an empty string, it will be assumed that the output should be Unicode (i.e. it's not encoded).  
Return value As String The converted string, or the same string if both SrcCharset and DestCharset are empty strings.  

Usage example:

Dim Mailer
'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 = "joe@mysite.com"
  Mailer.Message.Subject = "International message"
  'Inform mail readers that the body contains UTF-8 data
  Mailer.Message.Charset = "utf-8"
  'Produce UTF-8 body
  Mailer.Message.BodyText = Mailer.Message.ConvertCharset("text with int. chars", "", "utf-8")
  Mailer.Send
  Mailer.Disconnect
End If

See Also:

Charset Property


Copyright 2002-2008, AfterLogic Corporation. All rights reserved.