How To Send Japanese Characters by Using CDO for Windows 2000 (284143)



The information in this article applies to:

  • Microsoft Windows 2000 Server SP1
  • Microsoft Windows 2000 Advanced Server SP1
  • Microsoft Windows 2000 Professional SP1
  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Exchange 2000 Server

This article was previously published under Q284143

SUMMARY

The following example demonstrates the code that is required to send Japanese double-byte character-set, using Collaboration Data Objects (CDO) for Windows 2000.

NOTE: You must have the input locale for Japanese set up on your computer.

MORE INFORMATION

  1. Create a new project in Visual Basic. Set up the form as follows:
    Object-------------------Name
    *************************
    Form ------------------ FrmTest
    Command Button ------ cmdSend
    Command Button ------ cmdQuit
    TextBox --------------- txtPort (Value: 25)
    TextBox --------------- txtServer
    TextBox --------------- txtTo
    TextBox --------------- txtFrom
    TextBox --------------- txtSubject
    TextBox (Forms 2.0)---- txtBody

  2. Add a reference to the CDO for Windows 2000 object library.
  3. Add the following code to the form:
    Private Sub cmdQuit_Click()
    Unload Me
    End Sub
    
    Private Sub cmdSend_Click()
    On Error GoTo errhand
    
    
    Dim objConfig As CDO.Configuration
    Dim objMessage As CDO.Message
        
        Set objConfig = New CDO.Configuration
    
        ' Set the configuration fields for this message.
        With objConfig.Fields
            .Item(cdoSendUsingMethod) = cdoSendUsingPort 
            .Item(cdoSMTPServer) = txtServer ' Set the SMTP server
            .Item(cdoSMTPConnectionTimeout) = 30
            .Item(cdoSMTPServerPort) = txtPort ' Set the port to communicate on
            .Item(cdoSendUserName) = "user1" 
            .Item(cdoSendPassword) = "user1"
            .Update
        End With
    
        ' Create the new message object.
        Set objMessage = New CDO.Message
        
        
        ' Set the message properties and send the message.
        With objMessage
            Set .Configuration = objConfig
            .MimeFormatted = True
            .Fields.Update
            .To = "<" & txtTo & ">"
            .From = "<" & txtFrom & ">"
            .Subject = txtSubject
            .TextBody = txtBody<BR/>
           
            ' Set the Character set for the Body Part.
            .TextBodyPart.Charset = cdoShift_JIS
            
            ' Get the plain text version of the message & decoded body part.
            Set IBodyPart = objMessage.TextBodyPart
            IBodyPart.GetDecodedContentStream
            .Send
        End With
    
    Set objMessage = Nothing
    Set mobjConfig = Nothing
    
    Exit Sub
    
    errhand:
    
    MsgBox "Error: " & Err.Number & " (" & Err.Description & ") occurred"
    
    Set objMessage = Nothing
    Set objConfig = Nothing
    
    End Sub
    
    					
    .
  4. Run the project.
  5. Type the name of your SMTP server in the txtServer field, and fill in the txtTo, txtFrom, and txtSubject fields.
  6. Paste the Japanese text into the txtBody field, or enter it with the Windows Input Method Editor (IME).
  7. Click cmdSend.

Modification Type:MinorLast Reviewed:7/13/2004
Keywords:kbhowto KB284143