Insert Message in many folders using Graph API (Microsoft Outlook) - outlook

In google mail API, a mail can have a list of parent Labels. So it can have multiple parents. I want to do similar in Outlook, but here we have to specifically define the ParentFolderId. Is it possible to do it in Outlook using graph API.

In the Exchange world, a message can only have a single parent. If you want a message to be present in multiple folders, it must be created in each and every folder. But these messages will be totally independent from each other, and can be modified or deleted without affecting any other messages.
There are search folders (you can see them in Outlook) that contains only pointers to messages in other folders (this is similar to what Google does), but most Outlook folders are not search folders.

Related

filter incoming emails in outlook

I would like to automatically put incoming emails which are not from certain domains go to a specific folder in outlook. For example I want any emails that are not from xyz.com and personname#gmail.com to go into a folder outside emails .
I found this link but it is not useful as i dont know the exact domains from where I would get those emails
I have Microsoft office 16
While creating filtering rules, MS Office doesn't provide filtering for NOT conditions. However, this can be achieved by adding exception to the rule. You'll be able to find it after you set the conditions and the actions.
I would suggest to process all messages with an exception of Sender address includes as the domain you want to whitelist (xyz.com). Similarly, you can add more exceptions to this rule.
You can refer to this article.

Send file via Teams (like MAPISendMail)

My (editor-like) Windows desktop program can create a new e-mail with the current project attached using MAPISendMail. A customer wants the same functionality for Microsoft Teams.
For the web version, I think I can probably do that with Graph API.
But I can't find anything for the desktop app version. Is there a way to do that?
Bonus:
It would be great if the user could manually specify recipient + body text in Teams (and not in my program).
So you can't actually attach files to messages directly - you basically upload the file to a web location, and then provide a link to the file in the message. As an example, you can upload to the SharePoint document library that exists in the "Files" tab (something like this). Then, in terms of sending the message, you can send to a Team/Channel quite easily using a Webhook. This does not support #mentions the moment though. Another option is to use Graph to send the message.
If you're wanting instead to send a kind of 'private' message to the user, you'd need to look into creating a bot, and sending a 'Proactive' message

Is there a way to open up a known Outlook email through Java 11? (Web or Local)

Short Version:
I want to open any specific Outlook email from my Java app, either locally through the Outlook app or through the website on a browser. I already have the email information like folder, message ID, UID, sender, receiver, etc but not the email ID used in the URL of the Outlook website. Does anyone know of a way to do either of these things through Java?
Long Version:
I'm creating a software for my company in Java that has a built-in email client for Outlook emails so the emails can be linked with jobs in various ways. So far I've been able to make good progress with the email client section in terms of displaying a list of emails and being able to display a chosen email, but recently I've realized creating a GUI for an email editor (keeping track of reply chains, dragging in images for inline attachments, etc) is quite the gargantuan task to do on my own(JavaFX's HTML Editor could use a lot of work).
My band-aid solution for now is to have my program open the chosen email up through either:
Some (Windows 10) system command by calling the Outlook desktop application to show the email by some sort of ID (maybe UID?). I know on some level that this is possible because our company has an old program written in C# that can indeed do that.
Opening up the system's default browser with a link to "https://outlook.office365.com/mail/folder_name/id/insert_id_here". This is my preferred solution.
Here are my problems with each option so far:
There doesn't seem to be any resource I could find that provides an answer to this. The closest I can find are threads that explain how to open the default mail application with options to pre-populate to/from/subject/body sections (not to mention you can't pre-populate the body with anything besides text! So much for reply/forward messages with HTML formatting and attachments!). Another problem is that the old program I mentioned displays emails by finding the Outlook application's files (presumably the local OST file). I have no idea how the old program's able to call Outlook to show emails and even then, there's a chance that there's no Java equivalent. I, however, am using JavaMail to load up my mail, as I think it's better to talk to the Outlook mail server to fetch/push mail updates rather than wait for the Outlook app to sync up. This creates a problem because even if I knew how to call Outlook, my application may be more up to date than the Outlook app (especially if Outlook is not already open) and if call before Outlook updates, Outlook wouldn't be able to show it.
Again, I can't seem to find a resource for explaining these URL IDs. They're not the same as the mail's UIDs, and they don't seem to be anywhere in the mail's contents when grabbing mail through JavaMail. The most I was able to get from research was that they were called "long IDs", as they were just long strings (seemingly non-sequential) but that might've just been a made-up name from the article as I've found no other references to it. There's a chance that they could be some sort of encoded UID but I didn't see any note of JavaMail having to decrypt to get UIDs in the documentation. I doubt I'd be able to make any more progress with this option, but if there's a solution similar to this (perhaps some sort of script that opens up Outlook online, searches by some identifier, like body contents, and pulls up the first result? Idk much about browser scripts) I'd be happy to hear it.

Microsoft Graph List Contacts API returns contacts beyond what are visible in the Outlook UI

Outlook UI
You can see that I've made three test contacts in the UI accessible here: https://outlook.live.com/people/
Microsoft Graph List Contacts API
When I call the List Contacts API (https://graph.microsoft.com/beta/me/contacts?$orderby=createdDateTime desc&$top=50), I get a list of contacts that is much more extensive than the list visible in the UI. These contacts appear to be anyone that has emailed me or anyone that I've emailed.
The problem
If I want to poll against the GET /me/contacts endpoint to get some data whenever I make a new contact, I'll end up getting notified every time someone new sends me an email or every time I send someone new an email (even if I didn't manually create the contact).
Is this intentional? If so, are there any filters I could add to specify that I don't want to get contacts that were not manually created by me? Looking over the JSON representation of a contact, I don't see anything I can filter on.
Possible Solution
My only thought is that I notice that the contacts made for me exist in a folder that is not returned in the contactFolders API endpoint. I could theoretically make a call to that endpoint and take the list of contacts returned and check if the parentFolderId exists in there. If it does, presumably that's because we created a contact and if not then it's made for us. That feels terribly hacky, though.
Thanks for the help!
This is an issue with the Microsoft Graph Beta APIs. Switching to the v1.0 of the Graph REST APIs resolved this.
It seems Outlook automatically adds every email address that had been in contact with the user as a hidden contact in a hidden folder.
The GET beta/me/contacts endpoint (unlike the v1.0 one) returns all contacts from all folders, so it also includes this hidden folder.
There are two ways to get the expected list of contacts:
Option 1 - get all contacts, and then filter:
GET /beta/me/contactFolders to obtain a list of "real" folders (this endpoint does not return that hidden folder)
GET /beta/me/contacts to get all contacts in the account
Filter the list of contacts by field parentFolderId - to keep only contacts in one of the folders returned at step 1
Option 2 - get contacts by folder:
GET /beta/me/contactFolders to obtain a list of "real" folders (this endpoint does not return that hidden folder)
for each folder returned call GET /beta/me/contactFolders/{folder-id}/contacts and aggregate the returned contact lists
Hope this helps.

Uniquely identify Messages on multiple inboxes using Graph API/Outlook REST API

I'm building an application for sharing office 365 emails between the users within an organization. I have a problem for uniquely identifying an email which is part of many users' inbox.
In detail, User A sends an email to user B & C, all are within a same organization with a domain abc.com. I tried with Office 365 Graph Mail API and i checked against each users individual mail box where same email appearing with different ids. Is there any way to uniquely identify the email for different inboxes?
When I tried with the Calendar API, there is a property called 'icaluid' which can be used for uniquely identifying the event across shared calendar views. Is there anything like this support for Mail API?
You might try the InternetMessageId property, which is available in the Beta version of the Outlook API (make sure "beta" is selected at the top of the page). If you're using Graph, it's on the v1.0 version of Graph.

Resources