I'm not sure, but I think the body of the email is automaticly encoded to
quoted printable (the plain text part), I think others in this list knows
better than me, long time ago I coded with the mail-components. If you use
html-mail, then you can encode all chars like this (C++, allthough I have
not tested this encoding on the body of the mail, only the header. Remember
that you need to set the content-type according to the encoding of the body
of the mail):
String Misc::MiscEncodeQuotedPrintable(WideString text)
{
   wchar_t tmp;
   for (int i = 1; i <= text.Length(); i++)
   {
        tmp = text[i];
      if (tmp > 126||tmp==95||tmp==61||tmp==63)
      {
         text.Delete(i,1);
         WideString qpID = "=" + AnsiString::IntToHex(tmp,2).UpperCase() ;
         text.Insert(qpID, i);
         i += qpID.Length() - 1;
      }
   }
   String returnString=text;
   return returnString;
}

It might be that you need to change all spaces to underscore between the
for-loop and returning the text, at least if the text is in the subject you
must do that.

If you use this form in the subject, the use the following form
String Subject = "=?iso-8859-1?Q?" +
Misc::MiscEncodeQuotedPrintable(OP_UTF8Decode(source)) + "?=";

To change the html-part of the mail, you can use this:
String Misc::WideStringToHTMLEncoding(WideString html)
{
   wchar_t tmp;
   for (int i = 1; i <= html.Length(); i++)
   {
        tmp = html[i];
      if (tmp > 126)
      {
         html.Delete(i,1);
         WideString htmlID = "&#" + String(tmp) + ";";
         html.Insert(htmlID, i);
         i += htmlID.Length() - 1;
      }
   }
   String ret = html;
  return ret;
}

This form can hold any possible char in html.

Regards Bjørnar

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Henrik
> Sent: 21. desember 2006 15:55
> To: 'ICS support mailing'
> Subject: Re: [twsocket] Freeze when using smtp after 
> recreating itsparentform
> 
> Hi Bjørnar!
> 
> I've not been experiencing any problem with character 
> replacement (å->e,
> ä->d and ö->v) with ICS components, only Indy 9 and only when passing
> through ms exchange it seems, but I tried Your suggestion and 
> it works like a charm with Indy 9! 
> (Do You mean that You use that approach also with ICS smtp 
> components?)
> 
> Quoted printable sounds interesting as well because one of 
> our customers report character replacing problems also with 
> the body when sending (Indy) automated emails to a customer 
> of theirs in Norway... Apparently all Swedish characters å, ä 
> and ö are substituted with ?.
> Perhaps it is possible to use Quoted printable on the whole 
> body? If You want you can send me the code to my private address. 
> 
> I must say I really like the help I've received in this forum 
> and I would really like to be able to switch to ICS. It is 
> sad that we couldn't solve the dll loading error that appears 
> on some machines...
> 
> Thank You very much!
> Best Regards
> Henrik
> 
> 
> 
> -----Ursprungligt meddelande-----
> Från: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] För Bjørnar Nielsen
> Skickat: den 19 december 2006 17:39
> Till: 'ICS support mailing'
> Ämne: Re: [twsocket] Freeze when using smtp after recreating 
> itsparentform
> 
> I use the same component and send norwegian, swedish and even 
> chinese chars in the subject (but Outlook can't show chinese 
> in the subject on my computer).
> 
> Use Quoted printable or Base64 to encode special chars. 
> Example for Base64 could be like this (C++):
> 
> HtmlSmtpCli1->HdrSubject = "=?utf-8?B?" +
> Base64Encode(UTF8Encode(SubjectInputFromUserEdit->Text)) + "?=";
> 
> If you have a GUI-component that can handle WideStrings, then 
> you can have any language in the subject using the above 
> form. First the unicode-string is UTF8-encoded, then it is 
> Base64-encoded and I think this form can hold any possible char.
> 
> If you use Quoted printable instead you would save a little 
> space because only the char's above 126 or so is encoded, I 
> have code for this too if you ar interested.
> 
> Regards Bjørnar
> 
> > imagine) so I'm planning to return to Indy as long as I can solve 
> > their issue with Swedish characters in the subject.
> 
> --
> To unsubscribe or change your settings for TWSocket mailing 
> list please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
> --
> To unsubscribe or change your settings for TWSocket mailing 
> list please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
> 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to