how can I view contacs in self created "Contact Subfolders" with "PHP-EWS"?
With this Code:
$request = new FindItemType();
$request->ItemShape = new ItemResponseShapeType();
$request->ItemShape->BaseShape = DefaultShapeNamesType::ALL_PROPERTIES;
$request->ContactsView = new ContactsViewType();
$request->ContactsView->InitialName = 'a';
$request->ContactsView->FinalName = 'z';
$request->ParentFolderIds->DistinguishedFolderId = new DistinguishedFolderIdType();
$request->ParentFolderIds->DistinguishedFolderId->Id = DistinguishedFolderIdNameType::CONTACTS;
$request->Traversal = ItemQueryTraversalType::SHALLOW;
$response = $client->FindItem($request);
I can only view contacts in the "Contacts Root Folder" but no created Users in self created "Contact Subfolders".
How can i fix this? Please with a small example.
Thanks
DistinguishedFolderIdType means WellKnown in EWS. As your Folder is created by you...
$request = new FindItemType();
$request->ItemShape = new ItemResponseShapeType();
$request->ItemShape->BaseShape = DefaultShapeNamesType::ALL_PROPERTIES;
$request->ParentFolderIds = new NonEmptyArrayOfBaseFolderIdsType();
$request->ContactsView = new ContactsViewType();
$request->ParentFolderIds->FolderId = new FolderIdType();
$request->ParentFolderIds->FolderId->Id = $psFolderGuid;
$request->Traversal = ItemQueryTraversalType::SHALLOW;
so first get the $psFolderGuid /id
Related
i want to read only unread email from outlook exchange server. below is my code. but it is showing all email(read+unread) from inbox.
<?php
require_once ('../mail3/php-ews-master/ExchangeWebServices.php');
require_once ('../mail3/php-ews-master/EWS_Exception.php');
require_once ('../mail3/php-ews-master/EWSType.php');
require_once ('../mail3/php-ews-master/NTLMSoapClient.php');
function __autoload($class_name)
{
// Start from the base path and determine the location from the class name,
$base_path = '../mail3/php-ews-master';
$include_file = $base_path . '/' . str_replace('_', '/', $class_name) . '.php';
return (file_exists($include_file) ? require_once $include_file : false);
}
//$message_id = ''; // Id of the email message
$ews = new ExchangeWebServices("webmail.bangla.com", "dd.test", "************",ExchangeWebServices::VERSION_2010);
$request = new EWSType_FindItemType();
$request->ItemShape = new EWSType_ItemResponseShapeType();
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::DEFAULT_PROPERTIES;
$request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::INBOX;
$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;
$result = $ews->FindItem($request);
var_dump($result);
?>
please let me know what can i do. i want to read only unread mail. after reading it should be mark as read.
Thanks in advance.
I'm attempting to plug a php based calendar management system into exchange 2007 calendars.
I have the below code setup at present.
$subject = 'Appointment with ..';
$request = new EWSType_CreateItemType();
$request->Items = new EWSType_NonEmptyArrayOfAllItemsType();
$request->Items->CalendarItem = new EWSType_CalendarItemType();
$request->Items->CalendarItem->Subject = $subject;
$date1 = new DateTime('2015-05-10T15:00:00+03:00');
$DateStart = $date1->format('Y-m-d H:i:00');
$date = new DateTime($DateStart);
$request->Items->CalendarItem->Start = $date->format('c');
$date1 = new DateTime('2015-05-10T17:00:00+03:00');
$DateEnd = $date1->format('Y-m-d H:i:00');
$date = new DateTime($DateEnd);
$request->Items->CalendarItem->End = $date->format('c');
$request->Items->CalendarItem->ReminderIsSet = false;
$request->Items->CalendarItem->ReminderMinutesBeforeStart = 15;
$request->Items->CalendarItem->Body = new EWSType_BodyType();
$request->Items->CalendarItem->Body->BodyType = EWSType_BodyTypeType::HTML;
$request->Items->CalendarItem->Body->_ = <<<EOD
<p><strong>Staff Attending</strong>:bob</p>
EOD;
$request->Items->CalendarItem->ItemClass = new EWSType_ItemClassType();
$request->Items->CalendarItem->ItemClass->_ = EWSType_ItemClassType::APPOINTMENT;
$request->Items->CalendarItem->Sensitivity = new EWSType_SensitivityChoicesType();
$request->Items->CalendarItem->Sensitivity->_ = EWSType_SensitivityChoicesType::NORMAL;
$request->Items->CalendarItem->Categories = new EWSType_ArrayOfStringsType();
$request->Items->CalendarItem->Categories->String = array(
'Client Meeting (Scheduled)'
);
$request->Items->CalendarItem->Location = "Showroom";
$request->SendMeetingInvitations = EWSType_CalendarItemCreateOrDeleteOperationType::SEND_ONLY_TO_ALL;
$request->Items->CalendarItem->RequiredAttendees->Attendee[0]->Mailbox->EmailAddress = "user#domain.com";
$request->Items->CalendarItem->RequiredAttendees->Attendee[0]->Mailbox->RoutingType = 'SMTP';
$n = 1;
$response = $ews->CreateItem($request);
This will setup an event in the users personal calendar just fine, but what I need to do is to get it to post to a public folder calendar which I have the folderID for.
If anyone could assist it would be greatly appreciated!
Try adding the line:
$request->SavedItemFolderId->FolderId->Id=$folder_id;
after the
$request = new EWSType_CreateItemType();
where $folder_id is your stupidly long microsoft folder id!!!!
I'm doing the same right now.
You have to replace the SEND_ONLY_TO_ALL with SEND_TO_NONE.
This means that we cannot send meeting invitations for appointments stored in a public folder (I've been trying to find a workaround for this problem for a couple weeks now).
I'm not sure if there are other problems in your request but this is surely an issue.
i am trying to add a event to a particular person's calendar ,
the person is decided based on html form the value is stored in send
The mail is sent but event is not set.
this is my php code..
<?php
require_once 'google-api-php-client-master/autoload.php';
require_once 'google-api-php-client-master/src/Google/Service/Calendar.php';
$client = new Google_Client();
// OAuth2 client ID and secret can be found in the Google Developers Console.
$client->setClientId('######.apps.googleusercontent.com');
$client->setClientSecret('###');
$client->setRedirectUri('https://www.example.com/oauth2callback');
$client->addScope('https://www.googleapis.com/auth/calendar');
$send = $_POST["to"];
echo "Welcome $send successfully set an event in your calendar";
if( $send == "abc")
{
$to = "abc#gmail.com";
$subject = "Sample Mail Project";
$txt = $_POST["txt"];
$headers = "From: xyz#gmail.com" . "\r\n" ;
mail($to,$subject,$txt,$headers);
$event = new Google_Service_Calendar_EventDateTime();
$event->setSummary('Appointment');
$event->setLocation('VIZAG');
$start = new Google_Service_Calendar_Event();
$start->setDateTime('2014-12-19T06:00:00');
$event->setStart($start);
$start = new Google_Service_Calendar_Event();
$end->setDateTime('2014-12-19T10:10:00');
$event->setEnd($end);
$attendee1 = new EventAttendee();
$attendee1->setEmail('abc#gmail.com');
// ...
$attendees = array($attendee1
// ...
);
$event->attendees = $attendees;
$createdEvent = $service->events->insert('primary', $event);
echo $createdEvent->getId();
}
According to the documentation you should do an event insert this way:
$event = new Google_Service_Calendar_Event();
$event->setSummary('Appointment');
$event->setLocation('Somewhere');
$start = new Google_Service_Calendar_EventDateTime();
$start->setDateTime('2011-06-03T10:00:00.000-07:00');
$event->setStart($start);
$end = new Google_Service_Calendar_EventDateTime();
$end->setDateTime('2011-06-03T10:25:00.000-07:00');
$event->setEnd($end);
$attendee1 = new Google_Service_Calendar_EventAttendee();
$attendee1->setEmail('attendeeEmail');
// ...
$attendees = array($attendee1,
// ...
);
$event->attendees = $attendees;
$createdEvent = $service->events->insert('primary', $event);
Or you can do it with the quickAdd() method:
$createdEvent = $service->events->quickAdd(
'primary',
'Appointment at Somewhere on June 3rd 10am-10:25am'
);
I have a task at hand which requires me to connect Exchange Online account and list all the calendar entries in PHP.
I have read through many Microsoft help doc but it all refers to c# code. Can someone please guide me through steps to achieve this using PHP.
Try this:
$ews = new ExchangeWebServices($host, $username, $password);
$request = new EWSType_FindItemType();
$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;
$request->ItemShape = new EWSType_ItemResponseShapeType();
$request->ItemShape->BaseShape =
EWSType_DefaultShapeNamesType::DEFAULT_PROPERTIES;
$request->CalendarView = new EWSType_CalendarViewType();
$request->CalendarView->StartDate = date('c', strtotime('01/01/2011 -00'));
$request->CalendarView->EndDate = date('c', strtotime('01/31/2011 -00'));
$request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderIds->DistinguishedFolderId =
new EWSType_DistinguishedFolderIdType();
$request->ParentFolderIds->DistinguishedFolderId->Id =
EWSType_DistinguishedFolderIdNameType::CALENDAR;
With this: https://github.com/jamesiarmes/php-ews
How do you get all unread mail in a users' exchange mailbox using PHP while using this class ?
I figured to first list a folders contents like this:
$ews = new ExchangeWebServices("mailserver.domain.local", "user", "pass");
$request = new EWSType_FindFolderType();
$request->FolderShape = new EWSType_FolderResponseShapeType();
$request->FolderShape->BaseShape = EWSType_DefaultShapeNamesType::DEFAULT_PROPERTIES;
$request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::INBOX;
$request->Traversal = new EWSType_FolderQueryTraversalType();
$result = $ews->FindFolder($request);
var_dump($result);
Only then I get this error:
Catchable fatal error: Object of class EWSType_FolderQueryTraversalType could not be converted to string
Is there anybody with experience with this class that can tell me what I'm doing wrong?
I do know that a string has to be passed, but it seems the class has just 3 constants without any functions or other properties..
I figured it out, in above example I had to use
$request->Traversal = EWSType_FolderQueryTraversalType::DEEP;
Since it only had the 3 constants.
But posting it here since I think it might be useful for anyone else looking to do the same, listing all mail in your inbox goes as follows:
$ews = new ExchangeWebServices("mailserver.domain.local", "user", "pass");
$request = new EWSType_FindItemType();
$request->ItemShape = new EWSType_ItemResponseShapeType();
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::DEFAULT_PROPERTIES;
$request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::INBOX;
$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;
$result = $ews->FindItem($request);