Garethp / php-ews

PHP Exchange Web Services
BSD 3-Clause "New" or "Revised" License
112 stars 45 forks source link

Creating a new email with .eml attachment #238

Open jonibi opened 2 years ago

jonibi commented 2 years ago

Hello,

I want to attach an .eml file to a Exchange Draft. The issue is that it attaches the message, but the MIME attachment in email is with

Content-Type: application/octet-stream

and it doesn't have a preview available for Outlook desktop.

$api->getClient()->CreateAttachment(array (
    'ParentItemId' => $mailId->toArray(),
    'Attachments' => array (
        'FileAttachment' => array (
            'Name' => 'message.eml',
            'Content' => file_get_contents('message.eml'),
            'ContentType' => 'message/rfc822'
        )
    ),
));

If I try to change ContentType' => 'message' it places on the email Content-Type: message/rfc822, but it has empty Content