Пример #1
0
 public function createTestMail($message = null)
 {
     $client = $this->getClient();
     if (!$message) {
         //Create a new message
         $message = new Type\MessageType();
         $message->setSubject('Test Message');
         $message->setBody('Test Draft Body');
     }
     //Set the message as not a draft
     $extended = new Type\ExtendedPropertyType();
     $fieldUri = new Type\ExtendedFieldURI();
     $fieldUri->setPropertyTag("0x0E07");
     $fieldUri->setPropertyType(Enumeration\MapiPropertyTypeType::INTEGER);
     $extended->setExtendedFieldURI($fieldUri);
     $extended->setValue(1);
     $message->addExtendedProperty($extended);
     //Save the message to our Test Folder
     $itemId = $client->sendMail($message, array('MessageDisposition' => 'SaveOnly'));
     $client->getClient()->MoveItem(Type::buildFromArray(array('ToFolderId' => array('FolderId' => $this->getTestFolder()->getFolderId()->toArray()), 'ItemIds' => array('ItemId' => $itemId->toArray()))));
     return $itemId;
 }
Пример #2
0
<?php

require_once "vendor/autoload.php";
use garethp\ews\API\Type;
$api = MailApi::withUsernameAndPassword('server', 'username', 'password');
//Create the message item
$message = new Type\MessageType();
$message->setSubject('Test Message');
$message->setBody('Test Draft Body');
//Set the message as not a draft using extended property types
$extended = new Type\ExtendedPropertyType();
$fieldUri = new Type\ExtendedFieldURI();
$fieldUri->setPropertyTag("0x0E07");
$fieldUri->setPropertyType(\garethp\ews\API\Enumeration\MapiPropertyTypeType::INTEGER);
$extended->setExtendedFieldURI($fieldUri);
$extended->setValue(1);
$message->addExtendedProperty($extended);
//Pass it to the Send Mail function, but to SaveOnly without actually sending the email
$itemId = $api->sendMail($message, array('MessageDisposition' => 'SaveOnly'));
//Move the mail message from the sent folder to whatever folder we want to send it to
$api->getClient()->MoveItem(Type::buildFromArray(array('ToFolderId' => array('FolderId' => $folderId->toArray()), 'ItemIds' => array('ItemId' => $itemId->toArray()))));