ANSMTP Developers Center > Internationalization with ANSMTP

Note: this article is only suitable for ANSMTP 6.4 or later.
For ANSMTP 6.3 or earlier version, please click here.

Introduction

This tutorial shows how to choose a correct character set for your email.

Character Set

If there are some non-ASCII characters in your email, you should specify Charset property to help the email client to learn what is the current character set so that current email can be displayed correctly. We also recommend you set HeaderEncoding property to 1.

The following code demonstrates how to send email with Simplified Chinese.

Private Sub SendEmail()
  Dim oSmtp As AOSMTPLib.Mail
  Set oSmtp = New AOSMTPLib.Mail

  oSmtp.Charset = "gb2312"
  oSmtp.HeaderEncoding = 1
  oSmtp.ServerAddr = "mail.adminsystem.net"  
  oSmtp.FromAddr = "test@adminsystem.net"
  oSmtp.AddRecipient "Support Team", "support@adminsystem.net", 0

  oSmtp.Subject = "Test"
  'suppose that there are some Simplified Chinese characters in email body.
  oSmtp.BodyText = "Hello, this is a test...." 
 
  If oSmtp.SendMail() = 0 Then
    MsgBox "Message delivered!"
  Else
    MsgBox oSmtp.GetLastErrDescription()
  End If
End Sub					

Code Page and UNICODE

Sometimes even we have set Charset and HeaderEncoding properties to the correct value, Asian language characters still appear as ??? in email body. It is likely that the Asian language has not been installed on your machine.

How to install Asian languages on my machine?
Control Panel->Regional and Languages Options->Languages
Private Sub SendEmail()
  Dim oSmtp As AOSMTPLib.Mail
  Set oSmtp = New AOSMTPLib.Mail

  oSmtp.Charset = "gb2312"
  oSmtp.HeaderEncoding = 1
  oSmtp.ServerAddr = "mail.adminsystem.net"  
  oSmtp.FromAddr = "test@adminsystem.net"
  oSmtp.AddRecipient "Support Team", "support@adminsystem.net", 0

  oSmtp.Subject = "Test"
  'suppose that there are some Simplified Chinese characters in email body.
  oSmtp.BodyText = "Hello, this is a test...." 
 
  If oSmtp.SendMail() = 0 Then
    MsgBox "Message delivered!"
  Else
    MsgBox oSmtp.GetLastErrDescription()
  End If
End Sub					

UTF-8 Encoding

UTF-8 uses multiple single bytes to represent non-ASCII characters, so UTF-8 supports all languages very well, the following code can help you to send email with any languages.

Private Sub SendEmail()
  Dim oSmtp As AOSMTPLib.Mail
  Set oSmtp = New AOSMTPLib.Mail

  
  oSmtp.Charset = "UTF-8"
  oSmtp.HeaderEncoding = 1
  oSmtp.ServerAddr = "mail.adminsystem.net"  
  oSmtp.FromAddr = "test@adminsystem.net"
  oSmtp.AddRecipient "Support Team", "support@adminsystem.net", 0

  oSmtp.Subject = "Test"
  oSmtp.BodyText = "Hello, this is a test...." 
 
  If oSmtp.SendMail() = 0 Then
    MsgBox "Message delivered!"
  Else
    MsgBox oSmtp.GetLastErrDescription()
  End If
End Sub					

Note*: Not all email client support UTF-8 decoding, sometimes you have to specify the corresponding code page based upon your situation.

Free Email Support

Not enough? Please contact our technical support team.

Support@EmailArchitect.NET
VIP@EmailArchitect.NET(Registered User)

Remarks
We usually reply emails in 24hours. The reason for getting no response is likely that your SMTP server bounced our reply. In this case, please try to use another email address to contact us. Your Hotmail or Yahoo email account is recommended.



2001-2010 © Copyright AdminSystem Software Limited. All rights reserved.   About us  Site Map