login about faq

Hi!

I use following code to get headers of e-mails and e-mails attached file names:

                MessageSet set = new MessageSet() { HasUids = true };
                    page.ForEach(u => set.InsertId(u));
                    bundle = _imap.FetchHeaders(set);

                if (bundle == null)
                    continue;

                for (int i = 0; i < bundle.MessageCount; i++)
                {
                    Email email = bundle.GetEmail(i);
                    if (email == null)
                        continue;

                    int uid = email.GetImapUid();

                    for (int k = 0; k < _imap.GetMailNumAttach(email); k++)
                    {
                        string name = _imap.GetMailAttachFilename(email, k);

And in some cases I get file name with wrong charset like this: "лЮЙПНЯ 1я йЮДПШ ver.16.ddx" (should be in russian), but email.FromName is good (in russian) for example - "Малай Елена Юрьевна".

Header of this email:

Received: by s1.TSDomain.ru id <01CF9089.E1169C90@s1.TSDomain.ru>;
     Wed, 25 Jun 2014 19:26:47 +0400
MIME-Version: 1.0
Content-Type: multipart/mixed;
    boundary="----_=_NextPart_001_01CF9089.E1169C90"
X-MimeOLE: Produced By Microsoft Exchange V6.5
Content-class: urn:content-classes:message
Subject: =?windows-1251?Q?RE:_=EC=E0=EA=F0=EE=F1=FB_=E8=EC=EF=EE=F0=F2=E0?=
Date: Wed, 25 Jun 2014 19:26:46 +0400
Message-ID: <17C289B9CC810D4EB1F7E719468BB05601B3A447@s1.TSDomain.ru>
In-Reply-To: <1B8258AC0445E14C96EDA7B0B784CC4D38D27C@mail.dinamika-avia.ru>
X-MS-Has-Attach: yes
X-MS-TNEF-Correlator:
Thread-Topic: =?windows-1251?Q?=EC=E0=EA=F0=EE=F1=FB_=E8=EC=EF=EE=F0=F2=E0?=
Thread-Index: Ac+QbKioSWzAa98fRFOmVGA+94Qz/QAG98pg
References: <1B8258AC0445E14C96EDA7B0B784CC4D38D27C@mail.dinamika-avia.ru>
From: =?windows-1251?Q?=CC=E0=EB=E0=E9_=C5=EB=E5=ED=E0_=DE=F0=FC=E5=E2=ED=E0?=<******@TopSystems.ru>
To: =?windows-1251?Q?=C5=F1=E0=EA=EE=E2_=D1=E5=F0=E3=E5=E9?=<*******@dinamika-avia.ru>
Cc: =?windows-1251?Q?=D0=E5=E7=ED=E8=F7=E5=ED=EA=EE_=C4=E5=ED=E8=F1_=C8=E2=E0=ED=EE=E2=E8=F7?=<***********@TopSystems.ru>
ckx-imap-uid: 43559
ckx-imap-isUid: YES
ckx-imap-seen: YES
ckx-imap-answered: NO
ckx-imap-deleted: NO
ckx-imap-flagged: NO
ckx-imap-draft: NO
ckx-imap-flags: \Seen
ckx-imap-totalSize: 127696
ckx-imap-numAttach: 1
ckx-imap-attach-nm-1: =?windows-1251?Q?=EB=DE=C9=CF=CD=DF_1=FF_=E9=DE=C4=CF=D8_ver.16.ddx?=
ckx-imap-attach-sz-1: 93880
ckx-imap-attach-pt-1: 2
ckx-imap-attach-enc-1: BASE64

What's wrong?

P.S. today I have understood that filename had been encoded with some encoder before Imap got it, but Imap decided that encoding was "windows-1251" - but it's not true.It's only my guess.

asked Jun 26 '14 at 11:33

kuligintim's gravatar image

kuligintim
316911

edited Jun 27 '14 at 04:35

Our Exchange server uses KOI8-R encoding, but when IMap receive mails from it in email header I see Windows-1251 encoding and wrong file attachment name

(Jun 27 '14 at 08:30) kuligintim

When downloading headers from an IMAP server, the attachment information is not coming from the MIME header. It is obtained from the BODYSTRUCTURE part of the raw IMAP response.

Set the imap.KeepSessionLog property = true, and then capture the contents of the SessionLog property. Post the SessionLog contents here. We only need to see the FETCH and the IMAP response that includes the BODYSTRUCTURE for an email with attachments that exhibits the problem..

link

answered Jun 27 '14 at 13:30

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

See session log:

----IMAP REQUEST----
aaat UID FETCH 25030 (UID FLAGS RFC822.SIZE BODYSTRUCTURE BODY.PEEK[HEADER])
----IMAP RESPONSE----
* 3063 FETCH (UID 25030 FLAGS (\Seen) RFC822.SIZE 668877 BODYSTRUCTURE (((("TEXT" "PLAIN" ("charset" "koi8-r") NIL NIL "QUOTED-PRINTABLE" 441 8 NIL NIL NIL)("TEXT" "HTML" ("charset" "koi8-r") NIL NIL "QUOTED-PRINTABLE" 4280 72 NIL NIL NIL) "alternative" ("boundary" "----_=_NextPart_003_01CF91E4.1C18AE5D") NIL NIL)("IMAGE" "PNG" ("name" "image001.png") "image001.png@01CF91FD.3A228D10" "image001.png" "BASE64" 3466 NIL NIL NIL) "related" ("type" "multipart/alternative" "boundary" "----_=_NextPart_002_01CF91E4.1C18AE5D") NIL NIL)("APPLICATION" "OCTET-STREAM" ("name" {25}
Бизнес-процессы 2014.docx) NIL {25}
Бизнес-процессы 2014.docx "BASE64" 658616 NIL ("attachment" ("filename" {25}
Бизнес-процессы 2014.docx)) NIL) "mixed" ("boundary" "----_=_NextPart_001_01CF91E4.1C18AE5D") NIL NIL) BODY[HEADER] {736}
Received: by s1.TSDomain.ru 
    id <01CF91E4.1C18AE5D@s1.TSDomain.ru>; Fri, 27 Jun 2014 12:45:12 +0400
MIME-Version: 1.0
Content-Type: multipart/mixed;
    boundary="----_=_NextPart_001_01CF91E4.1C18AE5D"
X-MimeOLE: Produced By Microsoft Exchange V6.5
Content-class: urn:content-classes:message
Subject: =?koi8-r?B?98zP1sXOycUgMw==?=
Date: Fri, 27 Jun 2014 12:45:00 +0400
Message-ID: <17C289B9CC810D4EB1F7E719468BB05601B3A636@s1.TSDomain.ru>
X-MS-Has-Attach: yes
X-MS-TNEF-Correlator: 
Thread-Topic: =?koi8-r?B?98zP1sXOycUgMw==?=
Thread-Index: Ac+R5AsDh6V5r391S+a/Dm6pbiTrWg==
From: =?koi8-r?B?78TOz8LV0sPF1yDrz87T1MHO1MnOIOHMxcvTwc7E0s/Xyd4=?= <Odnoburtsev@TopSystems.ru>
To: <Kuligin@TopSystems.ru>,
    <testdocs@mail.ru>

)
aaat OK FETCH completed.
link

answered Jun 30 '14 at 03:53

kuligintim's gravatar image

kuligintim
316911

Any ideas? Our mail client works incorrectly because we have this problem.

link

answered Jul 10 '14 at 10:06

kuligintim's gravatar image

kuligintim
316911

The problem is still actual. :(

link

answered Oct 14 '15 at 10:45

kuligintim's gravatar image

kuligintim
316911

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×174
×22
×18
×6

Asked: Jun 26 '14 at 11:33

Seen: 19,325 times

Last updated: Oct 14 '15 at 10:45

powered by OSQA