Zugriff auf Outlook Webaccess

Aufgabenstellung:

  1. Erstellen einer Mail mittels EWS (Outlook Webaccess SOAP WSDL API)
  2. Erstellen eines Anhanges an die Mail.
  3. Start des Webaccess mit dieser neuen Mail.

Weitere Infos:

Genutzt wurde das „Framework“ http://code.google.com/p/php-ews/

Einfach die Sourcen runterladen und includieren.

Eine sehr gute Beschreibung für Methoden fand ich unter:

http://msdn.microsoft.com/en-us/library/bb409286%28v=exchg.140%29.aspx

Beispielcode

<?php

include „php-ews/ExchangeWebServices.php“;
include „php-ews/EWS_Exception.php“;
include „php-ews/EWSType.php“;
include „php-ews/NTLMSoapClient.php“;
include „php-ews/NTLMStream.php“;

foreach ( glob( „php-ews/EWSType/*.php“ ) as $filename ) {
include $filename ;
}
include „php-ews/NTLMSoapClient/Exchange.php“;

$ews = new ExchangeWebServices(‚exchange.domain.local‘, ‚domain\user‘, ‚pw‘,’Exchange2010′);

// Mail erstellen
$request->MessageDisposition = ‚SaveOnly‘;
$request->SavedItemFolderId->DistinguishedFolderId->Id = ‚drafts‘;
$request->Items->Message->ItemClass = ‚IPM.Note‘;
$request->Items->Message->Subject = “;

$request->Items->Message->ToRecipients->Mailbox->EmailAddress = ‚ews@elis.de‘;
//$request->Items->Message->Categories->String = $category;

$request->Items->Message->Body->BodyType = ‚HTML‘;
$request->Items->Message->Body->_ = ‚PDF Mail‘;

$response = $ews->CreateItem($request);

print_r($response);

echo $response->ResponseMessages->CreateItemResponseMessage->Items->Message->ItemId->Id.“n“;
echo $response->ResponseMessages->CreateItemResponseMessage->Items->Message->ItemId->ChangeKey.“n“;

// Anhang hinzufügen
$reqatt->ParentItemId->Id = $response->ResponseMessages->CreateItemResponseMessage->Items->Message->ItemId->Id;
$reqatt->ParentItemId->ChangeKey = $response->ResponseMessages->CreateItemResponseMessage->Items->Message->ItemId->ChangeKey;
$reqatt->Attachments->FileAttachment->Name=’test.pdf‘;
$reqatt->Attachments->FileAttachment->IsInline = true;
$reqatt->Attachments->FileAttachment->Content=file_get_contents(‚c:temptest.pdf‘);
$resatt = $ews->CreateAttachment($reqatt);
print_r($resatt);

// OWA ID Auslesen
$reqews->DestinationFormat=’OwaId‘;
$reqews->SourceIds->AlternateId->Format=’EwsId‘;
$reqews->SourceIds->AlternateId->Id=$response->ResponseMessages->CreateItemResponseMessage->Items->Message->ItemId->Id;
$reqews->SourceIds->AlternateId->Mailbox=’user@domain.local‘;
$resatt = $ews->ConvertId($reqews);
print_r($resatt);

// IE starten
shell_exec(’start iexplore „https://exchange.domain.local/owa/?ae=Item&a=Open&t=IPM.Note&id=&#8216;.$resatt->ResponseMessages->ConvertIdResponseMessage->AlternateId->Id.’&s=Draft“‚);

?>

Bloggen auf WordPress.com.

Nach oben ↑

%d Bloggern gefällt das: