jstedfast / MimeKit

A .NET MIME creation and parser library with support for S/MIME, PGP, DKIM, TNEF and Unix mbox spools.
http://www.mimekit.net
MIT License
1.81k stars 368 forks source link

MimeKit 2.0.4: Wrong number of attachments #409

Closed FSGRSolutions closed 6 years ago

FSGRSolutions commented 6 years ago

First of all, thank you so very much for your work and dedication on this project. Using v2.0.4 of MimeKit and MailKit, and every now & then the MimeMessage.Attachments returns an IEnumerable with the wrong number of attachments or 0 when there should be at least 1. Let me know where to send the protocol logs so you can inspect them.

jstedfast commented 6 years ago

A MIME part is ONLY considered to be an attachment if it has a Content-Disposition: attachment header. Does it have that? If not, then it's not an attachment.

FSGRSolutions commented 6 years ago

From the POP3 Protocol Log:

S: From: <xxxxxxxxxxx@xxxxxxxxxxx.com>
S: To: <xxxxxxx@xxxxxxx.com>
S: Date: Fri, 22 Jun 2018 14:49:14 -0500
S: Subject: XXX XXXXXX Invoice 35877 
S: Content-Type: multipart/mixed;
S:  boundary="--boundary_26_a97744c9-4713-4a63-8bec-a65696010a1c"
S: X-ASG-Orig-Subj: XXX XXXXXX Invoice 35877 
S: Message-ID: <bbac0b15dc494fbc98cccc60ef7a7318@pcalakexch05.ad.packagingcorp.com>
S: X-Barracuda-Connect: UNKNOWN[172.16.1.135]
S: X-Barracuda-Start-Time: 1529696995
S: X-Barracuda-Encrypted: ECDHE-RSA-AES256-SHA384
S: X-Barracuda-URL: https://198.140.128.88:443/cgi-mod/mark.cgi
S: X-Barracuda-BRTS-Status: 1
S: X-Virus-Scanned: by bsmtpd at packagingcorp.com
S: X-Barracuda-Scan-Msg-Size: 2
S: X-Barracuda-Spam-Score: 0.80
S: X-Barracuda-Spam-Status: No, SCORE=0.80 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=1000.0 tests=BSF_SC7_MV0760, NO_REAL_NAME
S: X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.52240
S:  Rule breakdown below
S:   pts rule name              description
S:  ---- ---------------------- --------------------------------------------------
S:  0.00 NO_REAL_NAME           From: does not include a real name
S:  0.80 BSF_SC7_MV0760         Custom rule MV0760
S: X-EOPAttributedMessage: 0
S: X-EOPTenantAttributedMessage: 2691a251-4c38-4643-af0b-0c0982f197bd:0
S: X-Forefront-Antispam-Report:
S:  CIP:198.140.128.88;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(8046002)(2980300002)(438002)(199004)(189003)(260700001)(86152003)(77096007)(26005)(122386005)(84326002)(564344004)(106466001)(2476003)(72206003)(4743002)(24736004)(108616005)(5000100001)(2876002)(7116003)(22186003)(562524006)(106002)(21480400003)(4610100001)(7636002)(8676002)(336012)(305945005)(356003)(2501003)(246002)(7596002)(1096003)(573454002)(110136005)(86362001)(476003)(58800400003)(426003)(14003)(126002)(16586007)(486006);DIR:INB;SFP:;SCL:1;SRVR:BYAPR14MB2183;H:pcalaklx01.packagingcorp.com;FPR:;SPF:Pass;LANG:en;PTR:pcalaklx01.packagingcorp.com;A:1;MX:1;
S: X-Microsoft-Exchange-Diagnostics: 1;BY2NAM01FT033;1:v8bKSYZP/igHNmKKbIsNY41HOS0WwrHe0WFTGSj2QMc3/4U1FSSo8hUOi7rOL4Cl3Xi/JxAQwyrbvl8BYKROCIi+HWAJ39hsxg4OxtcIvvW/Dd890aqxQ4NzZmafIQcK
S: X-MS-PublicTrafficType: Email
S: X-MS-Office365-Filtering-Correlation-Id: c9598c41-41f4-4950-828f-08d5d8795527
S: X-Microsoft-Antispam:
S:  UriScan:;BCL:0;PCL:0;RULEID:(7020095)(5600026)(711020)(4605076)(4608076)(4614076)(49563074)(1401150)(1402068)(71702078);SRVR:BYAPR14MB2183;
S: X-Microsoft-Exchange-Diagnostics:
S:  1;BYAPR14MB2183;3:6dna1NedBL3LVDyYOC5i6ETT71Mnl2AcCgE9fLPmB+FsgoTirio5xTZQQFA3Dem6hdCnlg7cQLTvgBfm9HSTT1X2k7lJhguvipvfkiE2BXzOmBBrb8DJOK3LUpVBGCim8ATocq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z+CkqMlo2aRjLwR+u0/3n7l9QEDTaoPSZM6XWeY8E8fpiJji/V7kKV6wR7pF4p2ceiFO00N812tKpM4YwM6zIdxbBr0vBQFpTbH9cxGBUuIPJaqzoL+;4:6Msg8WjcmqRES2FIsj4hkRbOgC3Nypsvv4LWtpB04HkT3T86tG7gUKQE+1LcdCx42rj8HVmP2J9VekQKVUOIqVopRPUYqEeHGMtldohygCwqgWRBO0o8451EKJ7H09qQOsKKaVCNrEASc28GOsg4vme3bg4QGI0stWV74RuV+lg=
S: X-Exchange-Antispam-Report-Test: UriScan:;
S: X-Exchange-Antispam-Report-CFA-Test:
S:  BCL:0;PCL:0;RULEID:(8211001083)(102415395)(7630418)(2401047)(8121501046)(7631346)(7632307)(7633261)(1430455)(1431068)(1432130)(1440212)(823300264)(823350442)(823411253)(9101536074)(93006095)(93004095)(3231254)(901025)(902075)(913088)(7045084)(944500087)(944510158)(944921075)(946803086)(946901078)(52103095)(52105095)(52106170)(52401190)(52601095)(52505095)(52406095)(52305095)(52206095)(3002001)(10201501046)(1610001)(8301001075)(8301003183)(9300000083)(9301000104)(201708071742011)(7699016);SRVR:BYAPR14MB2183;BCL:0;PCL:0;RULEID:;SRVR:BYAPR14MB2183;
S: X-Microsoft-Exchange-Diagnostics:
S:  =?us-ascii?Q?1;BYAPR14MB2183;23:+D38AR0OlF+h0GXU5hbXIgc1Sezx1W4AKJPPqUH4e?=
S:  =?us-ascii?Q?dyCEDEgXRTM6A967YWw4/iyxFv7mq8ZnapX5jSG/LSTU3/IKhN80ljTS86mK?=
S:  =?us-ascii?Q?7Ef3qTpUulTIGFmoU589XSVSV43sSEbiArWpyRCxA6Vrl1O+u+R5goJEgrio?=
S:  =?us-ascii?Q?XVIZNTEAFQKC1man756blAZD9jq0K/WqW2DZ+Bq4pWaATxkDQMSYdUvxnvlr?=
S:  =?us-ascii?Q?Bry6GN/rqzoCnDtszIXh1IEkkVD3tlrnFVQewAFvnzb+DFbJEA5RjbcI4V1z?=
S:  =?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qeUxBuTpq3UFVq2GGLp9yipmOuH8hRIjS5qPc7R+6MBDVFAUw/J8v5wli8MQtjIcM3hrE5SK6XiF2nBcCNsn08lX1w+lUtXG4vAZc=;7:/WcmrKHhETGH5N3uBTJ5YVNVIkZ+jxStQAwbmO7R77nwc/m6lusYNKplnGWm0K4Emdf+MvcBCyk8y44HM1dxRJxvKjgMxp+xD4vbKDC0RDbCtghsjsLFWHsZUQqPRXfhmQ/SCAhoLP0Gbxr5R6hs+70vERe2lNqqOfCugt3bkynzWukpVqqvGajiLgfLCSCDiMmRkdHQT9+ow3jhhk85sQb4CpHNC9fkkGXvUmUTsUKR9d00aI+7Ri17W7Z5EkEN
S: SpamDiagnosticOutput: 1:99
S: SpamDiagnosticMetadata: NSPM
S: X-OriginatorOrg: sealedair.onmicrosoft.com
S: X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2018 19:49:57.2682
S:  (UTC)
S: X-MS-Exchange-CrossTenant-Network-Message-Id: c9598c41-41f4-4950-828f-08d5d8795527
S: X-MS-Exchange-CrossTenant-Id: 2691a251-4c38-4643-af0b-0c0982f197bd
S: X-MS-Exchange-CrossTenant-FromEntityHeader: Internet
S: X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR14MB2183
S: X-MS-Exchange-CrossPremises-OriginalClientIPAddress: 198.140.128.88
S: X-MS-Exchange-CrossPremises-AuthSource:
S:  BY2NAM01FT033.eop-nam01.prod.protection.outlook.com
S: X-MS-Exchange-CrossPremises-AuthAs: Anonymous
S: X-MS-Exchange-CrossPremises-TransportTrafficType: Email
S: X-MS-Exchange-CrossPremises-TransportTrafficSubType:
S: X-MS-Exchange-CrossPremises-SCL: 1
S: X-MS-Exchange-CrossPremises-Antispam-ScanContext:
S:  DIR:Incoming;SFV:NSPM;SKIP:0;
S: X-MS-Exchange-CrossPremises-Processed-By-Journaling: Journal Agent
S: X-OrganizationHeadersPreserved: BYAPR14MB2183.namprd14.prod.outlook.com
S: 
S: ----boundary_26_a97744c9-4713-4a63-8bec-a65696010a1c
S: Content-Type: text/plain; charset="us-ascii"
S: Content-Transfer-Encoding: quoted-printable
S: 
S: =0A=0A
S: ----boundary_26_a97744c9-4713-4a63-8bec-a65696010a1c
S: Content-Type: application/octet-stream; name="Inv35877.pdf"
S: Content-Transfer-Encoding: base64
-serialized content after-
jstedfast commented 6 years ago

Notice that there is no Content-Disposition: attachment header. Therefor, by definition, they are not "attachments"... hence why they are not in the Attachments collection.

You need to use the BodyParts property instead.

FSGRSolutions commented 6 years ago

Is there anything I can tell the person sending the email that they're doing "wrong"? or any workaround you can recommend?

jstedfast commented 6 years ago

Just use the BodyParts instead.

FSGRSolutions commented 6 years ago

of course! thanks sir!!