Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Nov : Sending a SMTP message with UTF-8 subject
| Subject: | Sending a SMTP message with UTF-8 subject |
| Posted by: | "Richard" (ritchie8..@yahoo.com) |
| Date: | Sat, 24 Nov 2007 02:29:08 |
Hello!
I want to send a mail that will contain unicode caracters in the body AND
some headers.
This is my code:
//I indicate that the headers contsin utf-8 text and should be encoded as
base64
procedure TForm1.MessInitializeISO(var VHeaderEncoding: Char;
var VCharSet: string);
begin
VCharSet := 'utf-8';
VHeaderEncoding:= 'B';
end;
procedure TForm1.TntButton1Click(Sender: TObject);
begin
SMTP.Host:= 'myserver';
SMTP.Port:= 25;
Mess.Encoding:= meMIME;
Mess.From.Address:= 'my@address';
Mess.From.Name:= UTF8Encode('Some WIDE string');
Mess.Recipients.EMailAddresses:= 'my@address';
Mess.Body.Text:= UTF8Encode('Some WIDE string');
Mess.Subject:= UTF8Encode(Some WIDE string);
SMTP.Connect;
SMTP.Send(Mess);
SMTP.Disconnect();
end;
When I receive the mail in OE, The at, Eudora, etc, I can see the text in
the body, but the headers are messed up. When I look to the rough message I
see that the headers "seem" to be OK: =?utf-8?B? etc... but they don't look
right in the clients. Some message created on OE have the same syntax and it
looks right. I'm sure I'm doing something wrong, but what?