Is it possible to get a mail message from Microsoft Graph just by its id without UserId / Mailbox name?
I found this: https://learn.microsoft.com/de-de/graph/api/message-get?view=graph-rest-1.0&tabs=http but it seems to need a user reference in all cases.
No to get Messages you need to use one of the Messages Endpoints which are either in the /Me context of /Users contact. If all you have is the Id and you want to work out which mailbox it came from then the Id does contain the MailboxGuid
Related
We are using Microsoft Graph API to send and receive emails. Just like outlook, during a reply is composed, we want to change, remove or add new recipients. However, MS graph api of replyall or reply does not allow changing any email address.
How can we achieve this functionality using MS Graph API ?
You should use create-reply endpoint https://learn.microsoft.com/en-us/graph/api/message-createreply?view=graph-rest-1.0&tabs=http
That will create a draft reply message (and return the Id for that) that you can then patch any way you want including updating the recipient addresses and replyto then you send that draft message.
My outlook account at work is a member of a group called GraphTest which has email address GraphTest#companyname.net.
I'm trying to use the graph explorer to access mail in that group's inbox.
When I run the query https://graph.microsoft.com/v1.0/users/graphtest#companyname.net/messages I get the error message
Group Shard is used in non-Groups URI.
When I replace graphtest#companyname.net with my own email it works. Also I've consented to the permissions Mail.Read and Mail.Read.Shared.
What does this error message mean, and how can I fix it?
https://graph.microsoft.com/v1.0/users/graphtest#companyname.net/messages
Firstly the above API call which you used is invalid because you are giving a group email id to get it from user like /users/graphtest#companyname.net/messages which is invalid.
Even there is no mention in documentation that we can use something like /groups/graphtest#companyname.net/messages.
You can get some details from List Conversations using something like this.
https://graph.microsoft.com/v1.0/groups/{group_id_only}/conversations
My team is building a ticketing system. The goal is when we receive a new email we create a new ticket. All responses to that email are saved on the same ticket.
We have these basic goals working in simple cases, however, there is one case that we are struggling to find a good solution for. A client will email us, which creates a ticket, and we reply back requiring information. The client will send our reply to someone internal to their company. Then they will send the response back to us by replying with "see below". This response will have the conversation between them and their co-worker in the comment section of the email. The comment section will also contain our entire email chain which we don't want to duplicate.
The issue we are having is grabbing the conversation they had from the comment section to include with their response of "see below" and add them to the ticket. The only method we have come up with to solve this is manually parsing the comment section of the email, however, this is error-prone.
Does anyone know of a better way of tracking conversations they send you through the email?
We are using msgraph internally to send and receive emails and using their apis they have uniqueBody and body, but they don't seem to have a way to break the body up into its different parts.
What I need any of these options
1- get list of unique bodies from the email chain without using conversation Id as it will not be sufficient in some cases.
2- get the previous conversation Id of the incoming email. I mean if that email is a list of emails and it forwards to me.
UUID uuid = UUID.randomUUID();
message.addProperty("InternetMessageId", String.format("%s",uuid.toString()));
send InternetMessageId with a unique identifier to grab conversation id
change order only
I am querying the Microsoft Graph API to get OneDrive files, like:
GET https://graph.microsoft.com/v1.0/me/drive/root/delta
There is a lastModifiedBy facet in the driveItem resource returned, but it only contains a displayName and id. I need the user's email based on that ID.
So I tried the endpoint from these docs, which is:
GET https://graph.microsoft.com/v1.0/users/{id}
Specifically, I have tried things like:
GET https://graph.microsoft.com/v1.0/users/45aa3379f269b493
But it always returns the exact same set of data (regardless of which id I pass in), which is the data from the https://graph.microsoft.com/v1.0/me endpoint.
My scopes are the following:
offline_access
files.read.all
user.read
user.readbasic.all
people.read
contacts.read
contacts.read.shared
Is there any reason that this endpoint is not returning the data for the specific user ID that I pass? Or is there an alternative way to get the user's email based on the information provided in lastModifiedBy?
Looking at theJSON you posted, I noticed your files have an id using the format xxxxxxxxxxxxxxxx!xxx (note the !). This tells me this is a personal Microsoft Account (MSA).
Since this is a Microsoft Account, there are no "users" beyond yourself. Graph will therefore disregard whatever id you provide and always return your own profile (/me). In order to use /users you need to be connected to an Azure Active Directory tenant.
You cannot pull profile information for other MSA/Outlook.com accounts. Were this supported it would introduce an unacceptable hole in MSA privacy/security.
I am using the Microsoft Graph SDK as downloaded from NuGet (1.2). I authenticate to Azure AD (using ADAL).
I am using Client Credentials flow (not authenticated as any particular user) and am using Application Permission roles to access resources.
We are going to set up one service mailbox with a bunch of aliases. The aliases are given to the clients. This is so they are emailing an address that has a meaningful name to them.
My app will run as a service, and routinely scan new emails in this inbox. It should find the To address, and depending on what alias was used, file the email in a location relevant to that client.
The resource I want is: GET /users/<id | userPrincipalName>/messages
However, there doesn't appear to be a method in the SDK for it.
I can get users with this:
IGraphServiceUsersCollectionPage filteredUsers =
graphApi.Users.Request()
.Filter("userPrincipalName eq 'user#domain.com'")
.GetAsync().Result;
When I loop through the collection, I can see that the User has a 'Messages' property, but it is always null.
If I manually build a request message with HttpClient I can get the messages.
The second problem is that the Recipient property is always the userPrincipalName of the mailbox. How can I get the alias that was used by the sender?
While you are able to get your collection of users successfully, you have to make another request to receive the messages. This would look something like:
IUserMessagesCollectionPage userMessages =
graphApi.Users["user_id"].Messages.Request()
.GetAsync().Result;
To answer your second question, at this time you cannot access the original recipient through the Graph API, but you can do this through EWS. This is due to the fact that you can only retrieve the SMTP message headers through EWS. You can read more about how to do this here.
If this is something you believe is valuable to you in the Graph, I would encourage you to post it in our UserVoice.
If you want to get the email as a file, you can simply get the body as bytes through the SDK:
byte[] asBytes = Encoding.Unicode.GetBytes(message.Body.ToString());