ANSMTP Developers Center > Internationalization with ANSMTP
Important notice:* This product has integrated to EASendMail SMTP Component, Please use EASendMail SMTP Component instead of ANSMTP SMTP Component.
Related Links:
Send Email in VB6 with EASendMail SMTP Component
Introduction
This tutorial shows how to choose a correct character set for your email.
How to send email with specified character set;
How to send email with specified codepage.
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.
|