How to read users email address using Oauth2?

I am creating a service that scans people via email for specific PDF attachments and indexes them. I implemented this with OAuth2 for Gmail , using their extensive Gmail API , which works great.

Now I want to implement the same for outlook/live/hotmail . So I searched, and I basically read that you can "Connect to Outlook.com IMAP using OAuth 2.0 " ( here ). The fact is that this implements a full IMAP connection. As far as I know, this is more for after-sales service applications, with which the user can view and send emails, and not for applications that need to download emails in the background (for example, mine).

I did not work with IMAP from the code, but the main problems that I see now are that:

  • If I read emails, they will be set to β€œread” in the user's inbox, which I obviously don’t want (I don’t want to interfere with the normal use of email by the user).
  • I need to either stay in touch with all email inboxes or constantly sort through all email inboxes to receive new emails.

My questions really are;

  • Is there no other way than IMAP to get outlook.com email users?
  • Or are my problems really not problems, and should I just create an IMAP receiver for all outlook email accounts?
+7
email outlook oauth imap hotmail
source share
1 answer

In response to point # 1, according to Max , you can use body.peak to avoid this.

In response to point # 2, according to triplee , you can connect to all accounts and then use the IMAP extension called IDLE .

In response to item # 3, I found the Outlook REST API , which includes options for reading email, and you can call GET https://outlook.office.com/api/beta/me/messages on a regular basis to get all messages in the user account, or you can call GET https://outlook.office.com/api/v1.0/me/messages on a regular basis to receive all messages in the user's mailbox. You can find a complete list of REST API operations here .

In response to paragraph 4, I believe that some of your problems are problems, while others are not. I believe that you have no technical problems. However, I believe that you are correct that IMAP is not intended for applications like yours, as shown in the Wikipedia article on IMAP , which states: mine),

In computing, the Internet Message Access Protocol (IMAP) is the standard Internet protocol used by email clients to receive email messages from the mail server over a TCP / IP connection. IMAP is defined by RFC 3501.

In addition, in RFC 3501 , which defines the original IMAP protocol, it refers to mail clients that are read from a paragraph (mine is bold)

Internet Message Access Protocol version 4rev1 (IMAP4rev1) allows the client to receive and process electronic messages on the server.

+1
source share

All Articles