Hi Ian
Since version 1.10, the mail gets corrupted when the
subject contains a umlaut(ä,ö,ü).
This is the header from a corrupted mail, the original
subject is: 'DataFormErrorState - Buttons für Farben
sind keine DnxWinControls'
Microsoft Mail Internet Headers Version 2.0
Received: from WS32SG ([192.168.1.117]) by mail.all-
consulting.ch with Microsoft SMTPSVC(6.0.3790.211);
Mon, 21 Feb 2005 12:58:21 +0100
Reply-To: "HelpDeskSoftware" <HelpDeskSoftware@all-
consulting.ch>
From: "HelpDeskSoftware" <HelpDeskSoftware@all-
consulting.ch>
To: "=?ISO-8859-1?Q?Z=FCger Thomas?=" <zueger@all-
consulting.ch>
CC: "Brunner Alex" <brunner@all-consulting.ch>
Subject: =?ISO-8859-1?Q?1399 - Aktualisiert: HelpDesk
1.2.2.0 - DataFormErrorState - Buttons f=
Return-Path: HelpDeskSoftware@all-consulting.ch
Message-ID:
<ACCOMM1ZcdwY6RYIWUS0000015d@mail.all-
consulting.ch>
X-OriginalArrivalTime: 21 Feb 2005 11:58:21.0082 (UTC)
FILETIME=[A372EFA0:01C5180C]
Date: 21 Feb 2005 12:58:21 +0100
Regards,
Thomas
Logged In: NO
It seams to me that this only happens when the subject is
longer than 76 characters -> MailEncoder.cs line 230 ff?
Logged In: YES
user_id=83842
Thanks Thomas, this is probably due to the encoder changes,
I'll have to dig further into it and take a look
Logged In: YES
user_id=1068867
Don't know if this will fix your problem, but apparently I never
sent in this fix. With these changes, I could send accented
subject lines up to 255 chars (I think Outlook is chopping it).
Actually, I was sending UNICODE which I know Outlook
doesn't handle in the subject so it gets "reduced" to ASCII.
OpenSMTP will only preserve unicode in the BODY if you
switch from ISO-8859-1 to UTF-8.
internal static string
ConvertHeaderToQP(string s, string charset, bool
forceconversion)
{
if (!forceconversion)
{
bool
needsconversion=false;
for (int i=0;
i<s.Length; i++)
{
if (s[i]
> 126 || s[i] < 32 || s[i] == '=' || s[i] == '?')
{
needsconversion=true;
break;
}
}
if (!
needsconversion)
{
return
s;
}
}
// TURNER.BSD MODIFIED
9/29/2004 GKW to fix encoding problems in outlook.
// appears from other
mailers that EACH line of QP must be wrapped
// also, spaces are replaced
with _
string[] lines = ConvertToQP
(s, charset).Replace("\r\n", "\n").Split(new Char [] {'\n'});
s = string.Empty;
for(int i=0; i<lines.Length;
i++)
{
// remove any
trailing '=' (line continuation tag)
if (lines
[i].EndsWith("=")) lines[i] = lines[i].TrimEnd('=');
s += "=?" +
charset + "?Q?" + lines[i].Replace(' ', '_') + "?=";
if (i<lines.Length)
s += "\r\n ";
}
return s;
}
/* Test subject line (in Turkish, I think. If ş=s, it's been
reduced):
Ramilin resimleri 3 kişisel, 5 genel olmakla toplam 8 sergide
gsterilmiştir. Ressamın resimleri ilk olarak Nahcivan zerk
Cumhuriyeti Genlik, Spor ve Turizm Bakanlığının Nevruz
bayramı trenleri erevesinde yaptığı "Yurdumuza Nevruz
gelir" şiarlı musabakada sergilenmiş ve birinci olmuştur. Bu
musabakaya Ramil 9 resmi ile katılmıştır. Aynı yıl Nahcivanda
yerleşen Ticaret Merkezinde ressamın ilk kişisel sergisi
aılmıştır. Bu sergide gen ressamın 60 resmi sergilenmiş ve
ziyaretilerin ilgisini ekmiştir. Ressamın ikinci kişisel sergisi
2001 yılında Nisan ayında Şerur Trk Lisesinde Bilim Sergisi
erevesinde aılmıştır.
Actually showed up in Outlook (only 255 chars)
Ramilin resimleri 3 kisisel, 5 genel olmakla toplam 8 sergide
gsterilmistir. Ressamin resimleri ilk olarak Nahcivan zerk
Cumhuriyeti Genlik, Spor ve Turizm Bakanliginin Nevruz
bayrami trenleri erevesinde yaptigi "Yurdumuza Nevruz
gelir" siarli musab
*/
Logged In: YES
user_id=1148645
Thanks a lot for your code, it solves the problem!
Regards,
Thomas