INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Mail containing swedish special characters

Mail containing swedish special characters

(OP)
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

RE: Mail containing swedish special characters

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

RE: Mail containing swedish special characters

(OP)
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

RE: Mail containing swedish special characters

try setting the email's character set..

CODE

MailMessage.Encoding := meMIME;
MailMessage.Body.Text := UTF8Encode(sMsg);
MailMessage.Subject := UTF8Encode(txtAmne.Gettext);
MailMessage.CharSet := 'UTF-8'; 

RE: Mail containing swedish special characters

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.

RE: Mail containing swedish special characters

(OP)
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

RE: Mail containing swedish special characters

I struggled with this same topic a few months ago, and this post on StackOverflow enlightened me.

RE: Mail containing swedish special characters

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close