Solved. Outlook Express before 2002 and Encoding

Hi everybody

I know it´s the thousand´s entry concerning this theme - maybe its too complicated…

I read and write a UTF-8 database. No problem so During “write” Operations im leaving Textfields “as the are” - that means I have some funny characters inside my tables… When I read from my DB Im going to convert each CHAR Field with a defineEncoding(rs.field(“whatever”).value, Encodings.UTF8). Everything works fine.

But now - I have to email this data…

All “defineEncoded” data is copied into a textarea, from there into a eMailMessage. My last step here is a

EmailMessage.bodyPlainText = ConvertEncoding(Texxtarea, Encodings.UTF8)

About 80% of our Customers are getting a perfect eMail. The rest of them (often equipped with an Outlook Express before 2002 (they cannot receive data in UTF8, as far as I know) receive no Ä, Ö, Ü etc). I tried several Encodings - nothing worked. Then I tested it with aone of our customers and sent each possible Encoding to his mailclient with the following

Dim m As EmailMessage
Dim t As String
Dim enc, gfC As TextEncoding

t = “ÄäÖöÜüß”

for i As Integer= 0 to Encodings.Count

m = new EmailMessage
m.AddRecipient "customer@customer.de"
m.AddCCRecipient "c.jung@tele-dialog.de"
enc = t.Encoding
gfC = Encodings.GetFromCode(i)
m.BodyPlainText = gfC.internetName+": "+ConvertEncoding(t, Encodings.GetFromCode(i))
m.Subject = "TEST # "+str(i)
WinEmailconsole.MailSocket.Messages.Append m

next

Is there a mistake? My customer received 95 different Encodings - there was none working…

What can I do?

really need your help, folks

Try with Windows1252 or IsoLatin1.

Thanx Beatrix, I will test it and give a feedback

Thats interesting Windows1252 is not to find in my List of Encodings and Latin 1 shows:

-----Ursprüngliche Nachricht-----

Cc: c.jung@tele-dialog.de
Betreff: TEST ISOLatin1

IsoLatin1ÄäÖöÜüß

One of these should be Windows1252: WindowsLatin1, WindowsLatin2, or WindowsLatin3.

its Latin1 - just found out - but didnt help. I sent

[code] Dim m As EmailMessage
Dim enc As String

m = new EmailMessage
m.AddRecipient “supervisor@tele-dialog.de
m.AddCCRecipient “c.jung@tele-dialog.de

m.BodyPlainText = “ASCII”+tf.Text // TF is a Textfield with “”
enc = m.BodyPlainText.Encoding.internetName
m.BodyPlainText = ConvertEncoding(m.BodyPlainText, Encodings.WindowsLatin1)
enc = m.BodyPlainText.Encoding.internetName // “ASCII”
m.Subject = “TEST WindowsLatin1”
WinEmailconsole.MailSocket.Messages.Append m[/code]

This came back

ÄäÖöÜüß

This looks like utf8 characters to me.

Yes - thats what i think too. Older System do not deal with UTF-8, especially Outlook Express. But waht can i do to solve it???

On the Outlook Express side:
You can set the encoding in Outlook Express to be UTF-8 (at least in Outlook Express shipped with Windows XP in 2001). If it’s an older version I don’t know, but then we are talking about an email client from the 90s - who is using that nowadays?

On the Xojo side:
Maybe use BodyEnriched (= RTF) instead of BodyPlainText?

yes I know - hard to believe… Don’t think we´re talking about some mom and pop store. The loudest one is accompany with more than 1000 employees. BTW - you can set the encoding in 2001 Outlooks but only for sending - not receiving as far as I see. So i will try to set the whole thing in RTF but I fear it won´t help. Thanks for your ideas.

How to change default encoding for incoming mail to UTF-8 in Outlook Express

must be older then… I tried to find it but there is just outgoing. But i will have another look. Give me an hour…

what does the charset attribute of the Content-Type header of the MIME-Section say? First the (transfer encoded) content should be in that charset (sender’s duty), second it’s the MUA should display the content respecting that charset (recipient’s duty)…

When I understand your question - im not sending an attachment. That means its empty.

and what is a MUA

MUA = http://en.wikipedia.org/wiki/Mail_user_agent = email client

Have you tried html with a nice charset? What do you use for Content-Transfer-Encoding? What is your Content-Type? Why do you first set the plain text of the message and then change the encoding?

You could also try to analyze mails your customer already has that show up correctly.

Beatrix, thanks for your explanation. Here is my Testcode…

[code] Dim m As EmailMessage
Dim enc As String

m = new EmailMessage
m.AddRecipient “supervisor@tele-dialog.de
m.AddCCRecipient “c.jung@tele-dialog.de

m.BodyPlainText = tf.Text // Textfield with Content “”

enc = m.BodyPlainText.Encoding.internetName

m.BodyPlainText = ConvertEncoding(m.BodyPlainText, Encodings.WindowsLatin1) // there is the conversion

enc = m.BodyPlainText.Encoding.internetName
m.Subject = "TESTing "+enc

WinEmailconsole.MailSocket.Messages.Append m // smtp is receiving the eMailmessage, nothing special i think
[/code]

Windows1252 is WindowsANSI, by the way. This is the prevalent encoding for windows.

Mails can be very very complex. Have you tried with a content-type? This is what I fished out of an mail of mine:

Content-Type: multipart/mixed; boundary="–==_mimepart_52fee5ba9c534_295f957874927a0"; charset=“utf-8”; format=“flowed”

You will only need the charset here and not the rest, of course. Have you read that up?

Why are you setting the PlainText 2 times?

[code] Dim m As new EmailMessage
m.AddRecipient “supervisor@tele-dialog.de
m.AddCCRecipient “c.jung@tele-dialog.de

dim theBody as string = “”
m.BodyPlainText = ConvertEncoding(theBody, Encodings.WindowsLatin1) // there is the conversion

Dim enc As String = m.BodyPlainText.Encoding.internetName
m.Subject = "TESTing " + enc

WinEmailconsole.MailSocket.Messages.Append m // smtp is receiving the eMailmessage, nothing special i think
[/code]

2 times sending happened in “the heat of the action”… I´m not deep enough in eMail to extract the content type. Isn’t that only for Browsers?

As innocuous as it might seem, the email stuff can be finicky of you touch it too much. Try Beatrix’ code, it wouldn’t surprise me if it just worked.