Forum Discussion

daniel_sl's avatar
daniel_sl
Copper Contributor
Jun 23, 2023

Using new Outlook addins with microsoft graph (PHP)

Hi all,

 

at the moment i use a VBA macro which is triggered in Microsoft Outlook ("old" offline version) and pushes the EntryID of the currently selected Email to a php-script.

The PHP script then pulls the Email-details from Exchange-Server and processes them.

 

The macro looks like this:

 

Option Explicit
Public Sub GetCurrentEmailInfo()
Dim currentExplorer As Explorer
Dim Selection As Selection
Dim currentItem As Object
Dim currentMail As MailItem
Dim email_id As String

Set currentExplorer = Application.ActiveExplorer
Set Selection = currentExplorer.Selection

email_id = Selection.Item(1).EntryID

CreateObject("Wscript.Shell").Run "https:\\[some_url]\[some_php-file].php?email_id=" & email_id
End Sub

 

Unfortunately i have heard thath with the new web based outlook, vba addons are no longer supported. Can you give me an example, how i can get a button in the new outlook which does exactly the same as the vba script?

 

I just want that a browser window opens, and the URL with email-ID is opened.

in the current PHP-script i use following code to convert the EntryID to an ID i need for the microsoft-graph PHP library:

 

$email_id=rawurldecode($_GET["email_id"]);

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ EMAIL-ID die von Outlook kommt (entryID) umwandeln in das benötigte Format (restID) START
// convert entryId to a byte array
$entryIdBytes = hex2bin($email_id);

// convert entryIdBytes into a base64 string
$urlUnsafeEntryIdBase64 = base64_encode($entryIdBytes);
$paddingCount = substr_count($urlUnsafeEntryIdBase64, "=");
$urlSafeEntryIdBase64 = str_replace("+", "-", $urlUnsafeEntryIdBase64);
$urlSafeEntryIdBase64 = str_replace("/", "_", $urlSafeEntryIdBase64);
$urlSafeEntryIdBase64 = rtrim($urlSafeEntryIdBase64, "=");
$urlSafeEntryIdBase64 = $urlSafeEntryIdBase64 . $paddingCount;

$email_id=$urlSafeEntryIdBase64;

 

Maybe with Outlook web-addon i don't need this decoding?

 

Any help is appreciated.

 

Thanks a lot for support.

 

Daniel

No RepliesBe the first to reply

Resources