tadams
Guest
|
Hi,
We are using adxOutlookEvents_NewMailEx to add the EntryIDs of new emails to a background polling queue that does processing on these emails when they arrive. We also persist these EntryIDs in case Outlook is closed before the processing is finished, and have a backup event that scans folders for new emails on startup in case the emails have been moved folder and so EntryID changes.
We've found that when loading back in the persisted EntryIDs to re-process them when the user restarts Outlook, all of them fail even though they are still in Inbox. This is because the EntryID is the short-term one that can only be used in the same Outlook session.
My question is whether you guys are planning to add support for returning the long term entryID in this event, I've found the below article that suggests there is a flag that might enable this?
https://blogs.msdn.microsoft.com/stephen_griffin/2011/03/02/mapicdo-and-long-term-entry-ids/
Thanks,
Tom |
|
Andrei Smolin
Add-in Express team
Posts: 18821
Joined: 2006-05-11
|
Hello Tom,
Are you saying that you call MailItem.Save, read the EntryID and it is a short-term one? I suppose this relates to the message store type used. What is it: Exchange? PST? IMAP folders? Are their any other details?
Actually, what you see doesn't belong to Add-in Express: this is the Outlook object model that provides us with *all* data; if OOM gives us a short-term EntryID, we have to live with this or look for a workaround. OOM may rely on the data provided by the implementation of this or that message store type; whence my questions above.
Also, the NewMailEx event doesn't let you find emails that Exchange receives while Outlook is closed (say, for the night time). We describe our approach to dealing with this task at https://www.add-in-express.com/creating-addins-blog/2011/11/10/outlook-newmail-custom-solution/.
Andrei Smolin
Add-in Express Team Leader |
|
tadams
Guest
|
Hi Andrei,
The NewMailEx event passes in a collection of EntryIDs
Private Sub adxOutlookEvents_NewMailEx(sender As Object, entryIDCollection As String) Handles adxOutlookEvents.NewMailEx
We split this collection into individual EntryIDs and add these to our processing queue. The problem is that these EntryIDs are the short form ones so only valid for the current session. As a temporary fix we can use them to get the long-term EntryID is to use the below function inside the newMailEx event before adding to our queue, however ideally I want to minimise the work we are doing in this event given it is in the main thread.
Function getLongTermEntryID(entryID) As String
Dim olNamespace As Outlook.NameSpace = Nothing
Dim olItem As Outlook.MailItem = Nothing
Dim longTermEntryID As String = ""
Try
Dim m As CheckRecipient.AddinModule = AddinExpress.MSO.ADXAddinModule.CurrentInstance
If m IsNot Nothing Then
olNamespace = m.OutlookApp.GetNamespace("MAPI")
olItem = olNamespace.GetItemFromID(entryID)
longTermEntryID = olItem.EntryID
End If
Return longTermEntryID
Catch ex As Exception
If ex.HResult = &H8004010F Then
createLogEntry(LogEntryType.InfoEntry, "EntryID not assigned to an item", entryID)
Else
My.LogManager.Local.Error(ex, MethodBase.GetCurrentMethod().Name)
End If
Return entryID
Finally
If olItem IsNot Nothing Then
Marshal.ReleaseComObject(olItem)
olItem = Nothing
End If
If olNamespace IsNot Nothing Then
Marshal.ReleaseComObject(olNamespace)
olNamespace = Nothing
End If
End Try
End Function
So my question is whether there is anyway the NewMailEx event could be extended / changed to provide a collection of Long-term EntryIDs, I'm not sure if that article I linked refers to this?
Thanks,
Tom
NB: we handle emails sent / received when Outlook is closed already as per your suggestion :-) |
|
Andrei Smolin
Add-in Express team
Posts: 18821
Joined: 2006-05-11
|
:) Great!
There's nothing you can do to make that (or any other) Outlook event to provide data other than it provides. Should I need to get a long-term EntryID, I would use the workaround that you use; actually, literally the same code.
I suppose you get 0x8004010f if a rule moves the item before your code runs.
Andrei Smolin
Add-in Express Team Leader |
|