I would like to add a mail item that embedded another mail as an attachment by using Item.Update(ConflictResolutionMode.AlwaysOverwrite). but hit the "An internal server error occurred. The operation failed" exception.
you can see I have a mail item that is embedded into another mail item as an attachment. but there is missing the attachment name. if I create the similar scenario manually, O365 will use the subject as the attachment name:
1, create a mail, the subject is "\"Cool\""
2, create a mail, drag the first mail into this new mail item;
3, you can see the attachment name is "\"Cool\""
so I set the attachment name to "\"Cool\"" in my code:
var itemAttachment = Item.Attachments.AddItemAttachment();
itemAttachment.Name = "\"Cool\"";
...
Item.Update(ConflictResolutionMode resolutionMode);
then the exception is throwing.
I tried to used the native .NET API to list all the invalid charts: System.IO.Path.GetInvalidFileNameChars(); but mentioned that not all of them will cause this error, just below chars:
'"'
'<'
'>'
'|'
'\t'
'\n'
'\v'
'\f'
so I need to know the list of the invalid chars there. any suggestion?
I would like to add a mail item that embedded another mail as an attachment by using Item.Update(ConflictResolutionMode.AlwaysOverwrite). but hit the "An internal server error occurred. The operation failed" exception.
I am using the Office 365, the MIME content is:
From: kenny2 wu kenny2@abc.onmicrosoft.com To: kenny2 wu kenny2@abc.onmicrosoft.com Subject: invalid Thread-Topic: invalid Thread-Index: AQHSUSF/4OYKzHRijUeo5ReBKCohQQ== Date: Thu, 8 Dec 2016 07:05:56 +0000 Message-ID: CY4PR11MB1592219CE4F24B6DC4FD2CE4A9840@CY4PR11MB1592.namprd11.prod.outlook.com Content-Language: en-US X-MS-Has-Attach: yes X-MS-Exchange-Organization-SCL: -1 X-MS-TNEF-Correlator: Content-Type: multipart/mixed; boundary="_004CY4PR11MB1592219CE4F24B6DC4FD2CE4A9840CY4PR11MB1592namp" MIME-Version: 1.0
--_004CY4PR11MB1592219CE4F24B6DC4FD2CE4A9840CY4PR11MB1592namp Content-Type: multipart/alternative; boundary="_000CY4PR11MB1592219CE4F24B6DC4FD2CE4A9840CY4PR11MB1592namp"
--_000CY4PR11MB1592219CE4F24B6DC4FD2CE4A9840CY4PR11MB1592namp Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
--_000CY4PR11MB1592219CE4F24B6DC4FD2CE4A9840CY4PR11MB1592namp Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
--_000CY4PR11MB1592219CE4F24B6DC4FD2CE4A9840CY4PR11MB1592namp--
--_004CY4PR11MB1592219CE4F24B6DC4FD2CE4A9840CY4PR11MB1592namp Content-Type: message/rfc822 Content-Disposition: attachment; creation-date="Thu, 08 Dec 2016 07:05:47 GMT"; modification-date="Thu, 08 Dec 2016 07:05:56 GMT"
From: kenny2 wu kenny2@abc.onmicrosoft.com To: kenny2 wu kenny2@abc.onmicrosoft.com Subject: "cool" Thread-Topic: "cool" Thread-Index: AQHSUSF5uFyKQ1GCSUuylFcm4mRWtA== Date: Thu, 8 Dec 2016 07:05:35 +0000 Message-ID: CY4PR11MB1592519D5C33B63F0F5D0BBFA9840@CY4PR11MB1592.namprd11.prod.outlook.com Content-Language: en-US X-MS-Has-Attach: X-MS-Exchange-Organization-SCL: -1 X-MS-TNEF-Correlator: x-ms-exchange-organization-originalclientipaddress: 25.173.156.132 x-ms-exchange-organization-originalserveripaddress: 25.173.156.161 x-ms-exchange-organization-submissionquotaskipped: False Content-Type: multipart/alternative; boundary="_000CY4PR11MB1592519D5C33B63F0F5D0BBFA9840CY4PR11MB1592namp" MIME-Version: 1.0
--_000CY4PR11MB1592519D5C33B63F0F5D0BBFA9840CY4PR11MB1592namp Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
--_000CY4PR11MB1592519D5C33B63F0F5D0BBFA9840CY4PR11MB1592namp Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
--_000CY4PR11MB1592519D5C33B63F0F5D0BBFA9840CY4PR11MB1592namp--
--_004CY4PR11MB1592219CE4F24B6DC4FD2CE4A9840CY4PR11MB1592namp--
you can see I have a mail item that is embedded into another mail item as an attachment. but there is missing the attachment name. if I create the similar scenario manually, O365 will use the subject as the attachment name: 1, create a mail, the subject is "\"Cool\"" 2, create a mail, drag the first mail into this new mail item; 3, you can see the attachment name is "\"Cool\""
so I set the attachment name to "\"Cool\"" in my code:
var itemAttachment = Item.Attachments.AddItemAttachment();
itemAttachment.Name = "\"Cool\"";
...
Item.Update(ConflictResolutionMode resolutionMode);
then the exception is throwing.
I tried to used the native .NET API to list all the invalid charts: System.IO.Path.GetInvalidFileNameChars(); but mentioned that not all of them will cause this error, just below chars: '"' '<' '>' '|' '\t' '\n' '\v' '\f'
so I need to know the list of the invalid chars there. any suggestion?
Kenny.