Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mail containing swedish special characters 1

Status
Not open for further replies.

Kenbla

Programmer
Oct 11, 2006
68
0
0
SE
Hi all, I have a Delphi XE application which sends mails upon request. It works rather well but I sometimes have a problem with the swedish special characters åäö and ÅÄÖ. When I send a mail to a number of recipients it looks OK for most of them but not for all! The special characters doesn't display correctly for those individuals!
I set the charset property like this: MailMessage.CharSet := 'utf-8';

I have also tried to use:
MailMessage.Encoding := meMIME;
MailMessage.Body.Text := UTF8Encode(sMsg);
MailMessage.Subject := UTF8Encode(txtAmne.Gettext);
None of the above have helped!
Some of the recipients run 64 bit Windows and they get the mail with corrupt special characters!
I should also mention that the recipients of the mail are spread all around the world.
Any suggestions?
Regards,
Kenbla
 
Have the readers that have trouble upgrade to a utf-8 compatible mail application. You've done the best you can, supplying the mail in the most universal format available [thumbsup2]
 
Thanks for your reply TonHu. I have noticed another thing: If I have any of the swedish special characters in the Subject part of the mail. The message looks OK, isn't that kind of interesting? Any explanation to that?
Regards,
Kenbla
 
try setting the email's character set..
Code:
MailMessage.Encoding := meMIME;
MailMessage.Body.Text := UTF8Encode(sMsg);
MailMessage.Subject := UTF8Encode(txtAmne.Gettext);
[i]MailMessage.CharSet := 'UTF-8';[/i]
 
What I mean to say is make sure that you set the CharSet last. Doing so before setting any of the other properties may prompt INDY to reset the character set to something else.
 
Thanks for your reply Majlumbo! CharSet := 'UTF-8' is my last line of code before sending the mail! So that was not my problem.
I find it interesting though that if I have any swedish special characters i the Subject part of the mail everything works fine! If there are no special characters in the Subject part it doesn't work (if the message part contains special characters)!
Can somebody explain that to me? Cause I don't get it![dazed]
 
I struggled with this same topic a few months ago, and this post on StackOverflow enlightened me.
 
Thanks majlumbo, my email messages looks good now thanks to you!! I had to change to ContentType to "MailMessage.ContentType := 'multipart/mixed';" when I had files attached to the mail!
My code looks liket this right now:
if lvwFiler.Items.Count > 0
then MailMessage.ContentType := 'multipart/mixed';
else MailMessage.ContentType := 'text/plain';

MailMessage.CharSet := 'utf-8';
IdSMTP1.Send(MailMessage);

Thanks again!

Regards,
Kenbla
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top