Whats the difference between EmailMessage.InternetMessageId and Item.Id
provided EmailMessage inherits from Item. Which one of these is serverid of the email message which is bound to change if the folder of the email changes?
The Internet Message Id is assigned by the sending MTA (Message Transfer agent) and is a part of the RFC spec see https://en.wikipedia.org/wiki/Message-ID. The ItemId is the Store identifier that EWS uses to access items see https://msdn.microsoft.com/en-us/library/office/dn605828(v=exchg.150).aspx for more details.
Which one of these is serverid of the email message which is bound to change if the folder of the email changes?
The EWSId will changes if an Item is moved or copied between folders the Internet messageId won't but its not guaranteed unique.
Related
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.
I came across this as the only other thing I could find that resembled what I'm asking: http://office-outlook.com/outlook-forum/index.php/t/84123/
I'm sending an email through Office 365's SMTP server as a notification that a form was submitted to my company email address (me#company.com) from our company RSVP email address (rsvp#company.com). I am setting the From Name to be the full name of the person filling out the form and the reply-to email as the person's email address textbox.
Here is an example of what part of the message header might look like:
To: <me#company.com>
From: Test User <rsvp#company.com>
Reply-To: <test.user#gmail.com>
In Outlook, since rsvp#company.com is an actual mailbox within our company, it automatically displays the sender name as "RSVP" (which I suppose is what was set when the mailbox was created). Is there a way to bypass this and display the sender name in the message header instead?
No. Exchange always resolves all sender and recipient names to their primary SMTP address and default name. Just the way Exchange works.
You can extract MIME headers and modify the message sender related properties on the client side after the message is received using Extended MAPI (C++ or Delphi) or Redemption (I am its author - use RDOSession.CreateOneOffEntryID / RDOSession.GetAddressEntryFromID / set RDOMail.Sender and RDOMail.Get_SentOnBehalfOf / RDOMail.Save). Note that OOM will not let you set the sender related properties even using MailItem.PropertyAccessor.
I'm developing an email app used on cell phone.
When I delete a message with MoveItems command (move the message to "Deleted Items" folder), server returns a new ServerId of "3:3" for the message.
But when I sync the "Deleted Items" with Sync command, server returns a ServerId of "3:1" for the same message.
This causes two messages with identical content but different ServerId in the "Deletd Items" folder.
Any ideas?
In ActiveSync, the server-assigned item IDs can change whenever a Sync occurs. It's frustrating to code against that, but the IDs assigned by Exchange are ephemeral and will frequently change.
Whenever significant changes are made to a Folder that requires a Sync, you have to guard against the ID changes by essentially clearing your current cached version of that folder's contents and replace it with what the server sends you. Correlating the new items to the old ones is very difficult, because ActiveSync offers no persistent unique identifier that travels with each item, AFAIK. Exchange Web Services (EWS) is more flexible in this regard and you can do it with that API.
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.
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.