jamesiarmes / php-ews

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

Getting FileAttachmentType Content #379

Closed JamesHlavac closed 7 years ago

JamesHlavac commented 7 years ago

Hi, I just started using you library and its great. Thanks.

Messages with attachments do no have actual content, just details. For example, here's a dump of 2 FileAttachmentType objects. One is an image, another is plain text:

object(jamesiarmes\PhpEws\ArrayType\NonEmptyArrayOfAttachmentsType)#83 (2) { ["FileAttachment"]=> array(1) { [0]=> object(jamesiarmes\PhpEws\Type\FileAttachmentType)#84 (10) { ["Content"]=> NULL ["IsContactPhoto"]=> bool(false) ["AttachmentId"]=> object(jamesiarmes\PhpEws\Type\AttachmentIdType)#85 (3) { ["RootItemChangeKey"]=> NULL ["RootItemId"]=> NULL ["Id"]=> string(180) "AAMkADI3YzdiNDA3LTIyZGEtNGJjOS04NTEwLTgwYTNhOWUwM2QzNABGAAAAAADM825iD+HaQo1vztDa49FvBwCrsVz81iYOQIRqXC/BNm/0AAAAAAENAACrsVz81iYOQIRqXC/BNm/0AAAbadZcAAABEgAQABuXqVfMT0hBnQ+5SNBgXuY=" } ["ContentId"]=> string(43) "9A5CA0416247CF4A963291D7F47F15E8@MARINE.LAN" ["ContentLocation"]=> NULL ["ContentType"]=> string(10) "text/plain" ["IsInline"]=> bool(false) ["LastModifiedTime"]=> string(19) "2017-01-05T21:08:18" ["Name"]=> string(11) "owaTest.txt" ["Size"]=> int(319) } } ["ItemAttachment"]=> NULL } object(jamesiarmes\PhpEws\ArrayType\NonEmptyArrayOfAttachmentsType)#190 (2) { ["FileAttachment"]=> array(1) { [0]=> object(jamesiarmes\PhpEws\Type\FileAttachmentType)#191 (10) { ["Content"]=> NULL ["IsContactPhoto"]=> bool(false) ["AttachmentId"]=> object(jamesiarmes\PhpEws\Type\AttachmentIdType)#192 (3) { ["RootItemChangeKey"]=> NULL ["RootItemId"]=> NULL ["Id"]=> string(180) "AAMkADI3YzdiNDA3LTIyZGEtNGJjOS04NTEwLTgwYTNhOWUwM2QzNABGAAAAAADM825iD+HaQo1vztDa49FvBwCrsVz81iYOQIRqXC/BNm/0AAAAAAENAACrsVz81iYOQIRqXC/BNm/0AAAbadZaAAABEgAQAKEN1//vevRDuW/XMr3m2Jc=" } ["ContentId"]=> string(43) "97D84F8E78FC214EA60C74E735662B15@MARINE.LAN" ["ContentLocation"]=> NULL ["ContentType"]=> string(10) "image/jpeg" ["IsInline"]=> bool(false) ["LastModifiedTime"]=> string(19) "2017-01-05T13:58:21" ["Name"]=> string(6) "bg.jpg" ["Size"]=> int(1095068) } } ["ItemAttachment"]=> NULL }

As you can see, the actual Content and ContentLocation of these files is null.

So, how would I download and save the above attached files? Does your lib support this functionality? An example would be great.

Thank you!

jamesiarmes commented 7 years ago

This is expected. You need a separate GetAttachment request to download attachments. See the messages/get-attachments example.

In the future, please complete the template when filing a new issue.