Get all changes to calendar in Outlook Web Add-in - outlook

I'm developing an add-in for Outlook Web (Outlook365 and Outlook.com) which needs to retrieve all changes in the calendar.
I tried to use the Calendar REST API, but when calling getCallbackTokenAsync to get the access token, the token I get is scoped, and when I call the Calendar REST API, I get this error:
{"error":{"code":"ErrorAccessDenied","message":"The api you are trying to access does not support item scoped OAuth."}}.
Does anyone have an idea about this or another way to get changed items?

I have same issue with this , just about attachments.
You need to set permissions of 'ReadWriteMailbox' in your manifest and then it's supposed to return 200 and not error..but right now there is a bug in outlook.
Read more here: Can't add attachment to message in outlook add-in using Outlook rest API
Good luck .

Related

How to send an email from an outlook office add on?

I am trying to build an outlook add on, using react. I looked everywhere trying to find something that uses the mailbox in which the addon has been opened from, to programmatically send an email to a specified user.
Something similar to the google's command:
GmailApp.createDraft(e.parameters.address, e.parameters.subject, e.parameters.body, {
htmlBody: e.parameters.body,
name: 'Automatic Sender'
}).send();
Is the mail-sending process available on outlook?
Outlook web add-ins work under the context of currently selected item only. OfficeJS doesn't provide anything for creating and sending emails programmatically.
In Outlook add-ins you may consider using EWS, see Call web services from an Outlook add-in for more information. Also you may take a look at the Graph API as a possible workaround.

Outlook add-in - attachment ID's not working correctly in desktop app, but work on web app

I've developed an add-in for Outlook, it needs to be able to access attachments to emails.
On the desktop app, if I move an email with attachments from a shared folder to my main inbox, then try to run the add-in on it, i get the error:
The specified attachment Id is invalid.
However, if I perform exactly the same operation through the web app, it works fine.
I have checked and the Office.context.mailbox.item.itemId and Office.context.mailbox.item.attachments[i].id are exactly the same whether on web or desktop.
Emails with attachments that have not been moved from a different folder, and emails without attachments work fine.
I am fetching the attachment on a remote server through a PHP script, using a callback token I orginally get from Office.context.mailbox.getCallbackTokenAsync. The requests are made via EWS requests.
I am running Office 365 and the Outlook version is 1910 (Build 12130.20390), running on Windows 10.
Can somebody please help?
After some helpful suggestions from #OutlookAdd-insTeam-MSFT, I've come to a solution for this.
The problem is, after moving a message from a shared folder to the main inbox, when using the desktop app, the Office.context.mailbox.item.attachments (created when we run Office.initialize) no longer returns the correct ID's, instead it seems to return the old cached/out of date ID's from before the email was moved. The ID's returned when using the web app are correct using this method.
However, requesting the ID's from the exchange server, via an EWS request (or a REST call, but I use EWS) always returns the correct attachment ID's, whether called from the web app or the desktop app.
So, the solution I have come to is to make sure and request all of the attachment ID's from the exchange server, rather than using the Office.context.mailbox.item object. It means adding in an extra step of having to get a callback token first to then be able to request the info from the exchange server, but it means you always get the correct ID's.
I hope this is of help to someone else.

Email thread detection in an Outlook add-in?

I'm designing an Outlook add-in and need to determine whether a selected message is part of a thread. Ideally, I'd also like to find related messages in said thread as well. Reading over the documentation, the conversationId property looks promising, though there doesn't seem to be a way to "get messages by conversationId."
Under the current version (1.4, non-preview) of the Outlook Add-in API, is it possible to detect that a message is part of a thread using the JavaScript API? Is it possible to then find other messages in the same thread?
ConversationId is part of the javascript API. This means that you can know the ConversationId for the Office.context.mailbox.item whose your add-in is focusing on. See documentation here
To my knowledge, there is no way to retrieve all mails for a given ConversationId using vanilla javascript and Office.js.
However, you may be interested in my answer here.
When something is not available with Office.js api for an Outlook
Add-in you can try to use the Exchange Web Services (EWS) or REST APIs to perform the action
You have basically two ways to request EWS from a mail add-in.
You can request directly the EWS with a SOAP request from your client
app. See method makeEwsRequestAsync in Office.context.mailbox(https://dev.outlook.com/reference/add-ins/Office.context.mailbox.html).
You can get an access token, send it to your server and make the request from
there.
For the specific case of retrieving conversations using the Outlook REST API, this answer may also be helpful.

Outlook 365: Keeping specific events in sync with external system

I'm developing an integration with Outlook in Office 365 using the latest office.js api for add-ins.
What I have currently is an add-in, which displays a side pane on the appointment compose form. Inside that pane I have the functionality to create an object in our external based on the appointment, taking the start/end times, subject, location etc.
So I have appointment A in the calendar of an O365 account, and object A in an external system.
Is there a way to keep those in sync? I don't see it could be possible using the Outlook Add-In Javascript API, but maybe using ics files, or the Outlook REST API, or Exchange EWS? I see here plenty of issues with the credentials, as the user has separate credentials in our system.
Any tips? I tried to send from our system an ICS file with same iCal UID, but Outlook ignores it.
You would want to to use the Outlook Push Notifications REST API in your web service to get polled when users make changes to their Calendar. Then use the Outlook Calendar REST API to sync changes from your system to their Calendar.

Office365 Outlook REST API's for approval/rejection of messages by moderator

In a recent post (How to retrieve ItemAttachment contents from Office 365 REST API?) API mentioned to retrieve attachments from within an attached EML is in plans. Is such API already available?
In case of mail flow rule to send a message to a moderator. Approval mail is sent to an approver with the original mail attached as eml. Is there an API to approve/reject the message, similarly to the web buttons approve/reject?
Thank you very much.
We were also looking for an answer to (2), but even now, apparently this is not possible via the REST API. There's one SO link that has a powershell script that claims to do this - see Approve email message via exchange EWS API, however, I don't see a clean solution yet.

Resources