Closed basementmedia2 closed 3 years ago
I'm not sure, I don't know what that format you're getting from your vba-script is. However, there is a convertId
function that's made to convert ID formats, maybe that's what you're looking for
Hi Gareth,
i tried you example but get the following error message ("Das erforderliche Attribut 'Id' ist nicht vorhanden" means "The required attribute 'Id' is not present":
Fatal error: Uncaught SoapFault exception: [a:ErrorSchemaValidation] Fehler bei der Schemaüberprüfung der Anforderung: Das erforderliche Attribut 'Id' ist nicht vorhanden. in /www/htdocs/w00c2ecf/sltime_2017/vendor/garethp/php-ews/src/API/NTLMSoapClient.php:118 Stack trace: #0 /www/htdocs/w00c2ecf/sltime_2017/vendor/garethp/php-ews/src/API/NTLMSoapClient.php(118): SoapClient->__call('ConvertId', Array) #1 /www/htdocs/w00c2ecf/sltime_2017/vendor/garethp/php-ews/src/API/ExchangeWebServices/MiddlewareFactory.php(18): garethp\ews\API\NTLMSoapClient->__call('ConvertId', Array) #2 /www/htdocs/w00c2ecf/sltime_2017/vendor/garethp/php-ews/src/API/ExchangeWebServices.php(497): garethp\ews\API\ExchangeWebServices->garethp\ews\API\ExchangeWebServices\{closure}(Object(garethp\ews\API\MiddlewareRequest), Object(Closure)) #3 /www/htdocs/w00c2ecf/sltime_2017/vendor/garethp/php-ews/src/API/ExchangeWebServices/MiddlewareFactory.php(32): garethp\ews\API\ExchangeWebServices->garethp\ews\API\{closure}(Object(garethp\ews\API\MiddlewareReques in /www/htdocs/w00c2ecf/sltime_2017/vendor/garethp/php-ews/src/API/NTLMSoapClient.php on line 118
Can you help me out again?
By the way:
in this line
$ews2007ItemId = new Type\ItemIdType($ews2007Id, $changeKey);
these two parameters are passed to the function
$ews2007Id, $changeKey
But where are they set? If they have to be set by me: What values do i have to put in?
Best wishes Daniel
To convert to the VBA script ID you'd need something like
$api->convertIdFormat(
$email->getItemId(),
Enumeration\IdFormatType::EWS_ID,
Enumeration\IdFormatType::EWS_LEGACY_ID,
'user@email.com'
);
Except you'd need to find out what the ID Format you want is. The list of formats that you can use is in this enum. As for converting from vba script, you'd need to construct your ItemId like:
$api->convertIdFormat(
new ItemIdType("00000000F7E0BE4F3627AA4E8FD869DCEC65F5DB0700EEE99177854A374AA9CF403BD8054D08000000024F6C00005CE35CA4A825034D954C37EBDBD11C4800024F9B45F50000"),
Enumeration\IdFormatType::EWS_LEGACY_ID,
Enumeration\IdFormatType::EWS_ID,
'user@email.com'
);
again, replacing EWS_LEGACY_ID
with whatever format your vba script ID actually is. Your vba-script ID does look like a hex string, so I'd start by seeing if it's a HEX_ENTRY_ID
format
Hi Gareth,
thanx again for your answer.
What i tried is now the following:
require_once "vendor/autoload.php";
use garethp\ews\MailAPI;
use garethp\ews\API;
use garethp\ews\API\Enumeration\DistinguishedFolderIdNameType;
use garethp\ews\API\Enumeration;
use garethp\ews\API\Type;
$mailbox_name="Posteingang";
$api = MailAPI::withUsernameAndPassword("myserver/user", "mypassword");
$inbox = $api->getFolderByDisplayName($mailbox_name, DistinguishedFolderIdNameType::MESSAGE_ROOT);
$api->setFolderId($inbox->getFolderId());
$mail = $api->getMailItems();
foreach ($mail as $email) {
$api->convertIdFormat(
$email->getItemId(),
Enumeration\IdFormatType::EWS_ID,
Enumeration\IdFormatType::HEX_ENTRY_ID,
'd.baeuerlein@sl-i.de'
);
$email = $api->getItem($email->getItemId());
$email_id=$email->getItemId()->getId();
echo $email_id."<br>";
}
Plan was to get listed the converted ID of each email.
But i get the following error:
Fatal error: Uncaught garethp\ews\API\Exception\ExchangeException: Die ID weist ein falsches Format auf. in /www/htdocs/w00c2ecf/sltime_2017/vendor/garethp/php-ews/src/API/ExchangeWebServices.php:417 Stack trace: #0 /www/htdocs/w00c2ecf/sltime_2017/vendor/garethp/php-ews/src/API/ExchangeWebServices.php(379): garethp\ews\API\ExchangeWebServices->getItemsFromResponse(Object(garethp\ews\API\Message\ItemInfoResponseMessageType)) #1 /www/htdocs/w00c2ecf/sltime_2017/vendor/garethp/php-ews/src/API/ExchangeWebServices.php(387): garethp\ews\API\ExchangeWebServices->drillDownResponseLevels(Object(garethp\ews\API\Message\ItemInfoResponseMessageType)) #2 /www/htdocs/w00c2ecf/sltime_2017/vendor/garethp/php-ews/src/API/ExchangeWebServices.php(367): garethp\ews\API\ExchangeWebServices->drillDownResponseLevels(Object(garethp\ews\API\Message\ItemInfoResponseMessageType)) #3 /www/htdocs/w00c2ecf/sltime_2017/vendor/garethp/php-ews/src/API/ExchangeWebServices/MiddlewareFactory.php(57): garethp\ews\API\ExchangeWebServices->processResponse(Obj in /www/htdocs/w00c2ecf/sltime_2017/vendor/garethp/php-ews/src/API/ExchangeWebServices.php on line 417
What am i doing wrong (sorry, i am a beginner ;-( Thank you for your patience ;-)
When you call convertIdFormat
it changes $email->getItemId()
to the new format (See here to see how that's done). If you want to keep both ID's, try this:
foreach ($mail as $email) {
$oldId = $email->getItemId()->getId();
$newId = $api->convertIdFormat(
$email->getItemId(),
IdFormatType::EWS_ID,
IdFormatType::HEX_ENTRY_ID,
'd.baeuerlein@sl-i.de'
)->getId();
$email->getItemId()->setId($oldId);
$email = $api->getItem($email->getItemId());
$email_id=$email->getItemId()->getId();
echo "Hex: {$newId}, EWS: {$oldId}";
}
Hi,
tried your code:
require_once "vendor/autoload.php";
use garethp\ews\MailAPI;
use garethp\ews\API;
use garethp\ews\API\Enumeration\DistinguishedFolderIdNameType;
use garethp\ews\API\Enumeration;
use garethp\ews\API\Type;
$data=array();
$mailbox_name="Posteingang";
$parent_id=$_GET["parent_id"];
$api = MailAPI::withUsernameAndPassword("myserver", "mypassword");
$inbox = $api->getFolderByDisplayName($mailbox_name, DistinguishedFolderIdNameType::MESSAGE_ROOT);
$api->setFolderId($inbox->getFolderId());
$mail = $api->getMailItems();
foreach ($mail as $email) {
$oldId = $email->getItemId()->getId();
$newId = $api->convertIdFormat(
$email->getItemId(),
IdFormatType::EWS_ID,
IdFormatType::HEX_ENTRY_ID,
'd.baeuerlein@sl-i.de'
)->getId();
$email->getItemId()->setId($oldId);
$email = $api->getItem($email->getItemId());
$email_id=$email->getItemId()->getId();
echo "Hex: {$newId}, EWS: {$oldId}";
}
But still get the same error:
Fatal error: Uncaught Error: Class 'IdFormatType' not found in /www/htdocs/w00c2ecf/sltime_2017/ajax_load_mailbox_inbox_test.php:36 Stack trace: #0 {main} thrown in /www/htdocs/w00c2ecf/sltime_2017/ajax_load_mailbox_inbox_test.php on line 36
What am i doing wrong? Or is the solution in the link you posted? https://github.com/Garethp/php-ews/blob/master/src/API.php#L478
You need to use
the IdFormatType
at the top of the file or go back to putting the namespace in. In my test code I just shortened the usage because that's what I'm used to
Ah! Now I get it, thank you!
Hi,
i want to create a custom button in outlook for archiving Emails. The plan is that a user selects an Email in Outlook and then presses the button. --> A URL with a php script is opened and the ID of the selected Email is transmitted via a parameter.
Problem: The "EntryID" i get via vba-script in outlook differs completely from the Email-ID i get with your library.
For example the Email-ID in outlook vba is: 00000000F7E0BE4F3627AA4E8FD869DCEC65F5DB0700EEE99177854A374AA9CF403BD8054D08000000024F6C00005CE35CA4A825034D954C37EBDBD11C4800024F9B45F50000
With the following piece of code;
of the same email i get the email-id: AAMkAGY2YjUxYTI1LTIzZGQtNDQ2Zi04ZGUxLWZhZmU2NzQxNTZlOQBGAAAAAAD34L5PNieqTo/YadzsZfXbBwDu6ZF3hUo3SqnPQDvYBU0IAAAAAk9sAABc41ykqCUDTZVMN+vb0RxIAAJPm0X1AAA=
So the question is: Is there a way to get teh EntryID i get via VBA with your library or to get the Email-ID that i get with your library, via VBA?
Would be great to get some support, thank you very much.
Best wishes Daniel