Sending Chinese in Email

  1. 6 months ago

    Tony L

    18 May 2017 Pre-Release Testers, Xojo Pro Hong Kong

    Hi All,

    I got problem when sending Chinese in email. All Chinese become strange characters in the email.

    dim mail as emailMessage
    dim content as string = DefineEncoding(TextField.text, Encodings.utf8) //also tried without define encoding

    mail.BodyPlainText = content

    Anyone can help?

  2. Beatrix W

    18 May 2017 Pre-Release Testers Europe (Germany)

    That won't work because the mail text will interpreted as IsoLatin or similar.

    Is it possible to set the ContentType in Xojo emails directly to something like

    Content-Type: text/plain;charset="GB2312"

    ? Otherwise, you could try to convert your TextField to html and send this instead of plain text.

  3. Tony L

    18 May 2017 Pre-Release Testers, Xojo Pro Hong Kong

    I tried to append headers for Content-Type, and charset, and tried different charsets, Chinese characters still appears garbage in the email message........

  4. Beatrix W

    18 May 2017 Pre-Release Testers Europe (Germany)

    I don't think that Xojo allows directly editing of content type. Have you tried to convert your text to html and send a html instead of a plain text mail?

    Of course, both CURL from the MBS plugin and the Chilkat plugin support more options for sending mails. I just tried with the Chilkat plugin and the chinese text comes across fine.

  5. Beatrix W

    18 May 2017 Pre-Release Testers Europe (Germany)

    I'm just testing sending mails anyways. Sending chinese text with Xojo also works - just not with plain text emails.

  6. Tony L

    18 May 2017 Pre-Release Testers, Xojo Pro Hong Kong

    Beatrix, can you show me how to convert a string to HTML? Sorry, I am still a newbie... Thanks

  7. Beatrix W

    18 May 2017 Pre-Release Testers Europe (Germany)

    As far as I can see I'm simply setting both plain text and html version to the same text:

    MailToCompany.bodyPlainText = "Name: " + TFName.Text.Trim + EndOfLine.Macintosh + "Email: " + TFEmailAddress.Text.Trim + EndOfLine.Macintosh + EndOfLine.Macintosh + EndOfLine.Macintosh + "Description of Error: " + EndOfLine.Macintosh + TAMessage.Text + EndOfLine.Macintosh + EndOfLine
    MailToCompany.BodyHTML = "Name: " + TFName.Text.Trim + EndOfLine.Macintosh + "Email: " + TFEmailAddress.Text.Trim + EndOfLine.Macintosh + EndOfLine.Macintosh + EndOfLine.Macintosh + "Description of Error: " + EndOfLine.Macintosh + TAMessage.Text + EndOfLine.Macintosh + EndOfLine

    If this doesn't work use a html template like this one

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </style>
    </head>
    
    <body>
    /////your mail text here
    </body>
    </html>

    And replace "/////your mail text here" with your mail text. Then use this as BodyHtml.

  8. Christian S

    19 May 2017 Pre-Release Testers, Xojo Pro Germany

    As far as I know the send mail class from our plugin works fine with Asian characters.

  9. David C

    19 May 2017 Pre-Release Testers, Xojo Pro Derby, ITM

    I have just sent an email to myself using the CURLSMBS plugin with Chinese text pasted in from www.apple.cn and it was received just fine:
    -image-

  10. Tony L

    19 May 2017 Pre-Release Testers, Xojo Pro Hong Kong

    Thanks Christian and David, I think this the solution for me. Does this mean that Xojo native does not support the same?

  11. Beatrix W

    19 May 2017 Pre-Release Testers Europe (Germany)

    As I wrote a couple of hours ago you need to assign your text to BodyHtml and then chinese text works, too.

  12. Christian S

    19 May 2017 Pre-Release Testers, Xojo Pro Germany

    With pure Xojo you need to figure out it yourself. With my plugins I made it ready to use for everyone.
    The plugin can probably do some details better.

or Sign Up to reply!