Hi @Shewalkar, Snehal Thank you for your guidance !! Based on your comments , we have set the permissions under Office 365 Exchange Online as you mentioned and we were able to get the token created. However , our code is unable to read the emails from the mail box with the current code we are using. Below is the code snippet we are using to connect to Inbox and read the mail. But we are getting Authenticate Failed exception in the log.
Properties props = new Properties();
props.put("mail.store.protocol", "imaps");
props.put("mail.imap.host", "outlook.office365.com");
props.put("mail.imap.port", "993");
props.put("mail.imap.ssl.enable", "true");
props.put("mail.imap.starttls.enable", "true");
props.put("mail.imap.auth", "true");
props.put("mail.imap.auth.mechanisms", "XOAUTH2");
props.put("mail.imap.user", emailInput.getReceiveEmailId());
props.put("mail.debug", "true");
props.put("mail.debug.auth", "true");
Store store = null;
Session session = Session.getInstance(props);
session.setDebug(true);
store = session.getStore("imaps");
store.connect("outlook.office365.com", usermailId, token);
Since we come across the Authentication failure, we tried with the Application permissions in Graph API and we tried to trigger the requests through postman and received the success response. Our application is in Java and we consume Graph API through Rest call and the job was able to read the mails successfully. But the job is not making the mails to 'read' status and job reads the same set of emails every time it runs.
Is there any built-in function/class available with Microsoft Graph which can be used to mark the emails as READ status. or mark the emails with Flag ? We were able to see a similar function/method exist in IMAP (ImapMailReciver.receive()) .So would like to understand whether a similar method is available with Graph .
Any recommendation would be highly appreciated. Thanks