Find the email aliases a message was actually sent to - microsoft-graph-api

Is there a way to get the email aliases address to which an email was originally sent from Microsoft Graph?
We have a single email account like main#company.com along with the multiple other associated email addresses (email aliases). Emails send to any of the aliases go to a to the same inbox as main#company.com.
If we send an email to alias#company.com and look at the message using https://graph.microsoft.com/v1.0/me/messages, it shows mail#company.com as the email address. We need to detect if it was sent to alias#company.com.
The information for the allies can be found in the email header and there is a potential workaround in the Outlook API:
https://outlook.office.com/api/v2.0/me/mailfolders/inbox/messages/{messageId}?$select=Subject,SingleValueExtendedProperties &$expand=SingleValueExtendedProperties($filter=PropertyId eq 'String 0x7D')
This returns an unstructured result which needs to be parsed and it is not very convenient. We are looking if there is a more direct way to get this from Microsoft Graph.

You can use the same $filter with Microsoft Graph. You simply need to switch PropertyId to simply id:
?$select=subject&$expand=singleValueExtendedProperties($filter=id eq 'String 0x7D')
Also note that don't need to both select and expand the singleValueExtendedProperties collection. Expanding will ensure it gets included.

Related

How can i retrieve only emails from "Focused" tab in outlook using Graph Api?

I am using the following api endpoint call to get emails from outlook:
First I run
https://graph.microsoft.com/v1.0/me/
to get the user id
Then I run
https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/Inbox/Messages
But Outlook has 2 tabs , "Focused" and "Other"
How can i get the emails in the Focused only ?
Filter messages by inferenceClassification property. The possible values are Focused and Other, which indicate whether the user considers that message as, respectively, more important and less important.
https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/Inbox/Messages?$filter=inferenceClassification eq 'focused'
For the signed-in user you can call
https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messages?$filter=inferenceClassification eq 'focused'
Resource:
Manage Focused Inbox

Getting Original Email Address Sent To When Recipient Is In BCC

I'm trying to use Microsoft Graph to get the original email address a message was sent to if it ends up there via BCC.
We're using MSGraph to get emails sent to a shared email inbox in the form of "AppInbox-1234#example.org", where "AppInbox" is the name of the shared inbox and "1234" is an id we use in the app. We have a rule that already moves the email to the shared "AppInbox", which in turn fires off our subscription that looks at the recipients and uses the ID to store contents the message.
This works great if the email address is in the "To" or "CC" fields. But if the email address is the "BCC" field, I can see the email itself, but not the address it was originally sent to (e.g. "AppInbox-1234#example.org"), which I would need for the ID.
When I look at the message itself I only see the empty collection
"bccRecipients": [],
The best lead I've had seems to be around ExtendedProperties, but I haven't been able to figure out how to get the original recipient.

How can I determine the original message of a reply?

Using Microsoft Graph, how can I determine which message an outgoing message is a reply to?
The internetMessageHeaders property is not available for items in the Sent Items folder of mailboxes (using the Graph API, at least -- they are available using EWS or IMAP). If it were, I'd look for the in-reply-to header. In the absence of this, is there something in the standard Graph message properties that will tell me this?
You can check the "Subject" or "bodyPreview" to check if the content contains "RE:", if the answer is yes, the message is reply to.
You can group the message by conversationId and then order by lastModifiedDateTime. This way can check if the message is the original one, if it is not ,it will be reply-to/follow-up one.
Get the message list first(/me/messages or /users/{id | userPrincipalName}/messages and so on), and then foreach the message id to call reply api(/users/{id | userPrincipalName}/messages/{id}/reply and so on). The result in the reply is a reply to.
To Test this, you can use the Graph Explorer first and then paste the JSON to a JSON viewer tool. For further use, you need to use net/java and so on to handle.
API reference: https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/message
https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/message_reply

How to filter outlook messages by attachment name or subject using “Microsoft Graph” rest API?

We have integrated outlook to our iOS application using Microsoft Graph API. We have a use case where we have to filter outlook messages by attachment name or by subject. We are using query parameters to hit graph API.
Link to microsoft documentation.
As per above documentation, $search parameter is used to filter outlook messages. When are hitting below API, we are getting wrong responses. It’s returning messages which have “Test Mail” in both subject and message body. But it should return only the messages whose subject line is “Test Mail”.
https://graph.microsoft.com/v1.0/me/messages?$search="subject:Test Mail”
The same problem we are facing when we filter messages by attachment name, by hitting below API. In fact we are getting a empty response in this case.
https://graph.microsoft.com/v1.0/me/messages?$search=“attachments:test.png”
Is the above URL formation is correct? Why we’re not getting desired response? Please help us out on this.
For searching Subject only, you can use:
/v1.0/me/messages?$search="subject:search term"
or a filter:
/v1.0/me/messages?$filter=contains(subject, 'my search term')
(in this method the search term must exactly match a portion of the subject string)
For searching attachments only, you must use the keyword 'attachment' instead of 'attachments' (exchange documentation):
/v1.0/me/messages?$search="attachment:search term"

What is the purpose of each parameter in a MailChimp unsubscribe URL?

In the following URL, that unsubscribes a user from a list:
http://xxxxx.us2.list-manage.com/unsubscribe?
u=87f537bccxx35e53a1890e0d9&
id=40dcxx6cd6&
e=c4aaxx1dd6&
c=9a6xx11963
What does each parameter do?
Today I had to learn what each nondescript parameter means so that I could generate URLs for each email I send through Mandrill. It wasn't that easy to discover their meaning, but here are the one's I've come up with and how I found out what they are.
http://xxxxx.us2.list-manage.com/unsubscribe?
u=87f537bccxx35e53a1890e0d9&
id=40dcxx6cd6&
e=c4aaxx1dd6&
c=9a6xx11963
URL format:
Protocol can be http or https.
Your username comes next
In the example, us2 is the MailChimp datacenter where your account resides. That's different for each account. (https://apidocs.mailchimp.com/api/2.0/) It's good practice to specify a DC even though the documentation says that it isn't required. Specifying it will cut down on unnecessary latency.
list-manage[n].com can work with or without the number at the end of the domain, or it can have a 1 or a 2. Changing that doesn't appear to matter, but I think it has something to do with their load balancing.
/unsubscribe can also be /subscribe or /profile (The latter appears to be dependent on the "e" parameter. (See below) When you don't specify it, it states, "List member profiles cannot be updated from test campaigns or archive pages" and if you specify an invalid value, you get an error page.
u Is a unique identifier for your account. Every list on your account uses it. (See http://kb.mailchimp.com/lists/signup-forms/find-the-unsubscribe-link-for-your-list for how you can view the various URLs for your account.)
id is your list ID
e is the euid as documented on https://apidocs.mailchimp.com/api/2.0/lists/subscribe.php
c I haven't seen this one yet, but my guess is that it's the campaign ID.
Also, when you wish to prefill subscribe and unsubscribe forms, you can use the following GET params.
EMAIL Allows you to enter the subscriber's email
MERGE1 Allows you to enter the subscriber's first name
MERGE2 Allows you to enter the subscriber's last name

Resources