CDO 1.21 and Unicode Text (Japanese, Chinese, Korean, etc)


CDO 1.21 and Unicode Text (Japanese, Chinese, Korean, etc)


 


Having issues using CDO 1.21 with multi-byte (unicode) languages such as Japanese, Korean, Chinese? Do you want a way to create an appointment item with Japanese text using CDO 1.21?  This is not as straight-forward as it should be, here is info to help.  You will probably will run into some issues, however it’s really not a Nihongo (Japanese) language issue.   

The message box does not support
Japanese text. Japanese strings in the VB6 environment don't show as Japanese. The VB6 development environment and many of its controls only support ASCII. This is why you cannot paste Japanese text into your code, see it in the debugger or paste it into a VB intrinsic text control. You can still work with the Japanese text, but you will have to use a UNICODE-based control/window to see it.

This problem has been resolved with .NET. The .NET development environment and the .NET controls and windows support Unicode; VB6 does not. This means that you can work with text from any language in the debugger, on any text control or window created with a .NET language. You can even paste
Japanese strings directly into VB.NET code. Overall Visual Studio .NET languages (VB.NET, C#, etc) are better suited for international product development than VB 6.  


 


Visual Studio 2002+ won't help with CDO 1.21 if you need to use managed code. Why?  Because CDO 1.21 is not supported under .NET code.  OK, back to VB6.  For VB6, you should be able to display Japanese (Unicode text) using a text box from the "Microsoft Forms 2.0 Library".  Just set a reference to "Microsoft Forms 2.0 Library" and use a text box from it.  Note that you MUST have the Japanese code pages installed on the box.  The standard VB6 controls would require you to set Japanese as the standard language for the machine and reboot the box in order to display the Japanese text properly.


 


Highlighting some things:


 


·         Unless you set the default language for the machine to Japanese, you will not be able to see Japanese text in the VB6 debugger or in the VB6 controls. 


·         You must install the Japanese Code pages on the machine in any case to see Japanese text. 


·         Internet Explorer uses its own rendering code for Japanese.


·         You will run into this problem with other multi-byte languages such as Korean and Chinese.


·         Be sure to set both the Local Id and Code Page prior to the call to logon. 


·         Be sure to set Local Id and Code Page correctly.


·         You may be able to use the text box from "Microsoft Forms 2.0 Library" to display Japanese text if Japanese is installed on the box.


·         If you need to see Japanese text in the VB6 debugger, then set the machines default code page to Japanese.


·         Visual Studio 2002 and later can display Unicode/Japanese text properly if the code page for the language (Japanese) is loaded on the box.


·         CDO 1.21 is NOT supported in .NET code. 


·         You can use all versions of unmanaged Visual C++ with CDO 1.21.  Unmanaged C++ may be an option if you need to use Visual Studio 2002+ for development with CDO 1.21.


 


The Sample:


 


Create a new VB app.
A component reference to the "Microsoft Forms 2.0 Library".
Add a reference to the "Microsoft CDO 1.21 Library"
Add a forms text box to your form.
Call this text box "txtBody".
Add a button to the form and paste-in the following code:

Code:
Dim oSession As MAPI.Session
Dim oFolder As MAPI.Folder
Dim oMsgs As MAPI.Messages
Dim oAppt As MAPI.AppointmentItem
Dim i As Integer
Dim sServer As String
Dim sUser As String

Set oSession = New MAPI.Session

sServer = "smarthost" 'TODO: Change this to the name of your server.
sUser = "somebody" 'TODO: Change this to the name of an email recipient

' Set the localid and codepage - this needs to be set BEFORE calling Logon
oSession.SetLocaleIDs CLng(1041), CLng(932)
oSession.Logon , , False, True, , , sServer & vbLf & sUser

' Get Calendar folder
Set oFolder = oSession.GetDefaultFolder(CdoDefaultFolderCalendar)

' Create a new
Appointment
Set oMsgs = oFolder.Messages
Set oAppt = oMsgs.Add


' Set up properties on the
appointment
With oAppt
.Subject = "Test create and
appointment"
.Location = "Test here"
.StartTime = DateAdd("h", 12, Date)
.EndTime = DateAdd("h", 13, Date)

.Text = txtBody.Text
.ReminderSet = True
.ReminderMinutesBeforeStart = 15
.Encrypted = True
End With

' Call Update to save the
appointment to the calendar
oAppt.Update (True)

oSession.Logoff

' Clean Up
Set oMsgs = Nothing
Set oAppt = Nothing
Set oFolder = Nothing
Set oSession = Nothing


 


 


Additional links:


 


Supported Code Pages


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/act/htm/actml_ref_scpg.asp


 


List of Localized MS Operating Systems


http://www.microsoft.com/globaldev/reference/oslocversion.mspx


 


WD2000: Supported Language ID Reference Numbers (LCID)


http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B221435


 


Supported Code Pages
 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/act/htm/actml_ref_scpg.asp


 


Exchange 2k3 had some fixes in this area in SP2:


http://support.microsoft.com/kb/904633



 



 

Comments (0)

Skip to main content