Updating use of a Microsoft365 resource mailbox from Basic Auth to Graph - msal

I have an application that sends many emails to users on behalf of a Microsoft365 resource mailbox (like info#something.com). We currently use SMTP basic auth with a username and password for these emails and I know this needs to be upgraded to use a Microsoft Graph API. Is there documentation for this anywhere? So far the best I've found was an answer that made me think it cannot be done https://learn.microsoft.com/en-us/answers/questions/964387/ms-graph-api-sendmail.html . The application is written in Java but I'd settle for instructions in any language.

Related

Outlook addin - js or api generate email file

I have an outlook addin that I've built using Yeoman. The addin communicates with a server API on my server to combine data from an email with additional data from a database that a user has saved against an email address. This is all working great.
Next I want to store a copy of the email server side, as a file on disk, .msg preferred but I'll take a .eml if thats the only option.
I have 2 options but don't know if either are possible. Either the addin generates the .msg file and posts it to the server API OR the server side API generates the .msg file directly. I have got the server side using the Outlook v2 API and able to pull back the email information when the client passes it the token, id etc. If it could just generate/download a .msg file server side this would be ideal.
As a side note, many of the Microsoft API pages point out the deprecation of the Outlook API in favor of the Graph API, however there are inconsistent links between the pages and it get confusing. I have discovered the token from getCallbackTokenAsync only works with the Outlook API and not Graph, but I cant find out a way to generate a graph compatible token. All the example code from MS uses Office.context.mailbox.restUrl which still gives the Outlook API url and not Graph!
So I guess I'm trying to find out if it's even possible to get/generate a .msg or .eml file either client side using outlook.js or server side using one of the api's. Thank you.
I can get message data both client and server side but cannot get a physical email file.
The Office JavaScript API (OfficeJS) doesn't provide anything for saving messages as msg files (or getting streams). The best what you could do is to use Graph API where you could get the EML file, see Get MIME content of a message for more information.
The server-side code may use the OAuth 2.0 On-Behalf-Of flow (OBO) to request a new access token with permissions to Microsoft Graph. Read more about that in the Authorize to Microsoft Graph with SSO article.
The on-behalf-of (OBO) flow describes the scenario of a web API using an identity other than its own to call another web API. Referred to as delegation in OAuth, the intent is to pass a user's identity and permissions through the request chain.
For the middle-tier service to make authenticated requests to the downstream service, it needs to secure an access token from the Microsoft identity platform. It only uses delegated scopes and not application roles. Roles remain attached to the principal (the user) and never to the application operating on the user's behalf. This occurs to prevent the user gaining permission to resources they shouldn't have access to. See Microsoft identity platform and OAuth 2.0 On-Behalf-Of flow for more information.
Eugene's answer is good. If ultimately you need to get that message to your backend service, using Graph as Eugune described would be the recommended approach. If for whatever reason you are still looking for a capability to access it on client using Office.js, it is not a part of the product. We track Outlook add-in feature requests on our Tech Community Page. Please submit your request there and choose the appropriate label(s). Feature requests on Tech Community are considered, when we go through our planning process. Note there is already a couple of similar ideas there, if you search for "eml" keyword, that you may want to upvote.

Outlook REST API - Application Permissions or Background Services

I'm currently using Microsoft Graph, but have been running into its limitation on the request size. Seeing as how the Outlook REST API doesn't have that limitation and is supposed to be very similar to the Graph API for mail related functions, I wanted to use the Outlook API for sending messages with larger attachments.
But is there a way to get application level permissions with the Outlook REST API? Or make calls without a user? The authentication approach I'm using with Microsoft Graph is the one outlined at https://learn.microsoft.com/en-us/graph/auth-v2-service and it would be nice to be able to do the same with the Outlook API.
My app is registered at the Microsoft Application Registration Portal, but the permissions there are only for Microsoft Graph. I have seen an article that mentions being able to edit the manifest in order to get permissions working with other APIs (like the Outlook API), but wasn't too sure about that.

How can I access Gmail's native API?

I would like to access Gmail's native API. Eg,
create a search folder
tag messages
other gmail-specific actions.
There's this similar question, however the question asker seems happy with developing contextual gadgets rather than actually accessing a user's email.
In before anyone mentions: IMAP and POP are generic, non search based protocols and do not provide full access to gmail. Neither gmail.com, nor any of the official Gmail native apps, use IMAP and POP.
Most webmail services have private, non-IMAP/POP APIs and protocols, eg, hotmail (back when it existed used HTTPMail which was reverse engineered and implemented by hotwayd).
I could run Android gmail with a proxy and attempt to reverse engineer the Gmail protocol itself, but I suspect others have had the same need in the past and may already have a solution.
I did find a list of client of Gmail clients on Gmail Agent API but they don't seem maintained past 2004.
Android's Gmail app is using Google Cloud Messaging (GCM) to push email messages/notifications and sync with the phone. I think that’s “the API” you are looking for. The bad news is that it is obviously very well protected.
You can get started for free with GCM's JSON REST API and use it for your push messaging projects, but forget about using it for your Gmail in the same fashion Google does. The only option for getting a similar efficiency would be using IMAP's IDLE extension, which uses also push.
Focusing on what you need, I think there are decent solutions for the use cases you have listed in your question… You could use a [**Google App Script**][4] or libs like [**GMail for Python**][5], which seems a valid option to me... from the [**GMail for Python GitHub**][6]:
Features
Search emails
Read emails
Emails: label, archive, delete, mark as read/unread/spam, star
Manage labels
If you are developing an Android mobile app Gmail Public Labels API could also be of your interest...
Hope it helps...
EDIT: Google just introduced its GMAIL API
Update June 2014: Google have announced access to the native gmail API.
The Gmail API gives you flexible, RESTful access to the user's inbox,
with a natural interface to Threads, Messages, Labels, Drafts, and
History. From the modern language of your choice, your app can use the
API to add Gmail features like:
Read messages from Gmail
Send email messages
Modify the labels applied to messages and threads
Search for specific messages and threads
https://developers.google.com/gmail/api/

Mail API - MailChimp VS Amazon SES VS mailgun

We are looking at integrating with some kind of mail service API but the key thing is we need extensive reporting. I cant get much details on this from the different providers short of contact them so I thought id just ask and find out if anyone knows which service has detailed reporting?
I assume Amazon SES would be the best choice (+ price is good) but confirmation that their service offers really good API reporting would help finalise my decision.
We will be hooking into their API for reporting and displaying the reports on our clients CMS. No, we dont want to redirect the client to any of the provider's login as we want all the clients website data centralised.
With Amazon SES you have all the reporting that you want, but you will have to generate it yourself. Clicks/Bounces/Opens - Amazon SES does not provide you with any of these out of the box, not by an API and not by their console.
Mandrill (which is mailchimp's api service) does provide much more extensive repoting built in, but last I checked, you can't access it by API, only in their dashboard.
I have no idea about mailgun
Well since asking this question I have landed up using MailChimp's API. At the time of asking I couldnt find info on a MailChimp API with reporting.
Great API and features but quite complex replicating their back-end within your own CMS (especially campaigns).

Access to GMail mailbox content with google-api

Is there a way to access a Gmail Mailbox using the google-api? I'm trying to do this from command line using Java FWIW.
I already have code in place that achieves this via IMAP so that is not what I'm looking for.
You can access GMAIL IMAPS and SMTP using XOAUTH authentication, see here :
https://developers.google.com/gmail/xoauth2_protocol
It is not really the google-api-java-client, it is plain IMAP/SMTP but authentication is OAUTH2.
After going through the Google API once again and considering this question did not get an answer in the past 6 days, I guess it is safe to say there is no other way aside from IMAP/S.
NOTE:
This question was initiated because I was told by numerous people that a certain Google API was available and preferable for this purpose. It seems they were all informed by the same person who was not able to show me his source of information and agreed that according to the documentation IMAP indeed is the only API available as of now.

Resources