jamesiarmes / php-ews

PHP Exchange Web Services
http://jamesarmes.com/php-ews/
MIT License
567 stars 302 forks source link

Getting file attachment of an item attachment #571

Open mcisar opened 4 years ago

mcisar commented 4 years ago

Probably answering my own question, but to save further head banging...

I'm essentially extracting calendar events out of Exchange to display on a web calendar. Each event in the calendar may or may not have an attachment. Was able to extract all of my test attachments no problem... testing on the client's live data seemed to be hit and miss (more miss). Finally did dump of the whole responseitem and bingo.

While my tests were all nice attached PDF files, The client's data was mostly attached emails (why... as it turns out, scan-to-email from their copier and then just attach the received email to the calendar instead of saving the attached PDF and attaching that). Of course to Exchange that's an item-attachment and not a file-attachment... whole different bowl of soup.

Is there any shortcut that can be made, or am I stuck with doing the call to get the attachments list of my calendar entry, the subsequent call to get it's attachments... another call to get the item-attachment... and yet another to get the attachment attached to it (and pray its a PDF and not another email attachment) ?

Mike

P.S. More head banging, just tried to use the ItemAttachment's AttachmentID but it reports back as invalid (it is longer than the other ids, in fact seems to be identical to the calendar event's ID but with more tacked onto the end). So how do I extract the Item Attachment?