Jump to content
omnibrain

MimeDecode.PartInfos[i].PFileName empty when Attchment name BASE64 encoded

Recommended Posts

Hi,

 

we run into the problem, that when receiving mails some attachments don't show up. We use SslPop3Client.OnMessageLine to read all line, add them to a TStringlist, put that into a memoryStream and then do mimeDecode.DecodeStreamEx(mailStream). This works, except for one customer. Analysing the "raw" mail, I can see that the name for the attachment part is encoded.

 

----boundary_51655_e3dbec97-f69f-48f1-b41b-3f7293127257
Content-Type: application/pdf;
 name="=?utf-8?B?VGFXYSBmw7xyIEhHLVNWIDM1MiB2b20gMjAuMDYuMjAyNSAwOV80OV8w?=
 =?utf-8?B?OC5wZGY=?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment

JVBERi0xLjUNCjQgMCBvYmoNCjw8L1R5cGUgL1BhZ2UvUGFyZW50IDMgMCBSL0NvbnRlbnRzIDUg
...........

If there is "clear text" in the name part it works, with this encoded text it doesn't work. Do you have any idea what's going wrong?

Share this post


Link to post

The TMimeDecodeW.PartNameW property should decode the inline MIME correctly, although PartName should have returned the encoded version.  This is because the unit was written in AnsiString times, and unicode added later to the W .  It's possibly due for rewrite to remove AnsiStrings.

 

However I'm not sure about the quotes around the name, I don't think we expect them for inline MIME. 

 

I can not test your MIME because DelphiPraxis has corrupted what appears to be fixed text with hidden unicode characters that can not be pasted into Delphi, or easily removed, so our MimeDemo sample is unable to decode your name value.  

 

Angus

 

Share this post


Link to post

Thanks for having a look.

I did not find the "raw string", that's why I copied what a regular mail client (emClient) presented as source code of the mail, when I used it to receive the mail. (emClient could decode the file name). It looks exactly like it's shown in the forum. quotes and question marks included.

I did not know about PartName/PartNameW, I will check this, but sadly earliest on wednesday. I will also try to extract the string name from the raw MessageLine.

Share this post


Link to post

Decoding just the inline MIME file name does work: 

 

Unicode Header: TaWa für HG-SV 352 vom 20.06.2025 09_49_08.pdf [CharSet=utf-8]

 

The forum problem is extra stuff being added:

 

n\n\n\n\t\u00a0\n\n\n\n----boundary_51

 

 Angus

 

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×