How do I determine the mailbox that contains a given item or folder with EWS? - exchange-server

I have a program that subscribes to multiple Exchange 2010 mailboxes using EWS Managed API's streaming notifications.
When I get a notification related to an item, I need to determine whose mailbox that item belongs to. I'm able to get the item's ID and the parent folder's ID, etc., but I don't see any way to determine what mailbox the item belongs to.

Ok, so if I understand your application correctly you are using Impersonation and create subscriptions for all impersonated users. And when you receive event from subscription you want to know for which user this event occurred. If that is the case can't you just keep your subscriptions mapped to user that subscription was created for?
Simple Dictionary<StreamingSubscription, ImpersonateduserId> would be enough
And when you get notification you get subscription object from NotificationEventArgs.Subscription property and find user id that subscription was created for in you map. From ImpersonatedUserId you can get smtp address (property Id) and you know which exatcly user that was.

private void OnNotificationEvent(object sender, NotificationEventArgs args)
{
string fromEmailAddress = args.Subscription.Service.ImpersonatedUserId.Id;
}
That's how you get the Mailbox's Email Address that the item belongs to.

Related

How to make ID what is returned by `Office.context.mailbox.item.ItemId` constant, so it is same in Compose and in Sent status of the email?

I'am developing addon for outlook. So for it I am using office.js api. In my addon I want the option to open emails in new window. I store emails ID in db.
Problem is that I "grab" Id of email when it is in compose status, for example, emails ID is AAA. I press sent btn and email now in Sent folder.
As it should, then I want to open that email using my addon, but I could not, reason that id of that email is now 'BBB'!
I checked it by pressing on that email in Outlook and calling this javascript code Office.context.mailbox.item.ItemId I found that email ID changed.
Question is how to make ID what is returned by Office.context.mailbox.item.ItemId constant so is the same in compose and in Sent status of the email?
In graph.api you have immutable ids but I do not see how to apply them in office.js.api
First of all, I'd recommend calling the Save method before retrieving the item Id. For example, the EntryID property available in the Outlook object model is set when an item is saved to the store.
Also different Outlook clients will return the itemId in the protocol they leverage. REST and EWS item Ids are escaped differently which is causing the difference between the itemId for the same item.
The id returned by Office.context.mailbox.item.itemId is an EWS item id. You can convert it to rest/graph item id by using Office.context.mailbox.convertToRestId.
In the desktop edition of Outlook the EntryId may be changed when an item is moved to another folder/store. Check it out whether this is the case.
Immutable ids are Graph specific. Ids in EWS (that is what JS addins use) and MAPI (used by both Extended MAPI - native Outlook API - and by the Outlook Object Model) change when an item is moved.
Your best option is to add your own custom property to the item and then search for it when the item in moved to a different folder.

Edit Google Calendar "From" and "Organizer"

I want to create event via google calendar api using Go. I found out that the sender (From) is whoever responsible in client_id I provide in the google API, in this case me. Can I edit this sender, so that it is not sent from me? At least I can edit the display name of the sender, the email I think will always be my email
Also about editing the organizer, I tried to use move action but it only moves the event, not change the organizer. Is there other way to edit organizer?
To address your questions:
1. Can I create an event from another address?
What you want can be done by creating a service account and performing domain-wide-delegation
What is a service account?
A service account is a special type of Google account intended to represent a non-human user that needs to authenticate and be authorized to access data in Google APIs - in your situation the Calendar API.
After creating the above mentioned service account, you will have to perform domain-wide-delegation and impersonate a user in your domain in order to be able to create the event wanted.
Now, when writing the code for your application, you will have the use the credentials that were created for this account in order to authorize the requests.
OR
If you want to specifically edit only the display name of the creator of the event, you can perform an update request:
PUT https://www.googleapis.com/calendar/v3/calendars/calendarId/events/eventId
And add in the request body this:
"creator": {
"displayName": "UPDATED DISPLAY NAME"
}
2. Can I edit the organizer?
According to the Calendar API Documentation:
organizer > The organizer of the event. If the organizer is also an attendee, this is indicated with a separate entry in attendees with the organizer field set to True. To change the organizer, use the move operation. Read-only, except when importing an event.
Therefore, the organizer can be changed/updated only when importing the event in question.
Reference
Authorizing Requests to the Google Calendar API
;
Creating A Service Account;
Calendar API Events Resource;
Calendar API Events:Update.

EWS Calendar Attendees

I am working with the Exchange Web Service and am able to retrieve calendar events using the FindItem function. I have the function returning the IDOnly and making an additional call to GetItem to get all the properties. I am able to get everything I need with the exception of Attendees who are outside of the firm.
For example, if my company has john#abc.com and joe#abc.com email accounts and I have a calendar item with both, the EWS API is correctly returning both those are attendees.
However, if I create an event with john#abc.com and johnsmithxxxxx#gmail.com, the gmail address does not get returned in the API response even though it shows up within Outlook. Is this by design or do I need to specify some additional parameter to have the EWS API return ALL attendees regardless if they have a mailbox on the exchange server or not?

How to get conversation id if we only have send-only permission of user outlook account?

Is it possible to get conversation id and message id of the messages sent by our app on behalf of the user who only given send only permission?
We want to send follow-up mails in the same conversation and there is no way we can do that without message id.
I'm afraid not. You need to have mail.read in order to find the message id and add to the conversation.
Also, it's important to note that the id is mutable and can change for any number of reasons (most commonly the mail item being moved to another folder). It is possible to get immutable identifiers for Outlook resources but this functionality is still in Preview so, for the time being, it really shouldn't be used in a production environment.

Outlook sent item internet header missing

I have written a C++ app that sync's Outlook emails with our central server DB. Incoming messages contain MessageID info in the internet header - I use this for key generation when placing the messages in the central DB. However, Sent Items in Outlook do not seem to have Internet Headers, so I am stuck for a static id I can use to generate a unique, static GUID for placing the message in the central DB. Multiple Outlook stores are being scanned for multiple users, each user running a copy of the sync program. To be clear, if Pete sends an email to Joe, the email in Pete's Sent Items folder needs the same id to be generated as the id generated for the email when it arrives in Joes Inbox folder - Pete & Joe are both running the sync software.
Does anyone know whether:
1. You can grab a static MessageID from a Sent Items email item
2. If not, is there another value within the Sent Items email that will be available to the sync app scanning the Sent Items folder, and available to the sync app scanning the Inbox that the email eventually arrives in.
Users could be running Outlook 2002 upwards.
Thanks very much.
The MAPI property PR_INTERNET_MESSAGE_ID is set for outgoing and incoming items.

Resources