Reputation: 4373
I am trying to make an Outlook 365 add-in that does the following:
When an email is flagged for follow up (Today, Tomorrow, This Week, etc):
When an email is UN-flagged for follow up:
I am looking at using VSTO but I have never used it or any other of the MS Office add-in tools.
I have too many questions, for starters:
As far as code, I have a blank slate (VB shown but will accept C# suggestions too):
Dim WithEvents currentExplorer As Outlook.Explorer = Nothing
Private Sub ThisAddIn_Startup(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Startup
'register a handler for the events I am interested in (need help here)
End Sub
Private Sub MyEventHandler(someEventObject)
'Get basic data (need help here too), eg:
Dim eventName = someEventObject.EventType
Dim EmailUniqueId = someEventObject.Uid
Dim EmailFrom = someEventObject.FromEmailAddress
Dim Subject = someEventObject.Subject
'Send an HTTP REST call (I know how to do that)
End Sub
FYI - I am a web developer so I naturally want to gravitate to a solution that would send an HTTP REST API call for this. However, if that is not possible I am open to other ideas for getting these event details out of Outlook, even going so low as to create a file that contains the basic event/email information in a folder that could be parsed by a scheduled job. This project is just something I am making for myself to use for work so it doesn't have to be elegant.
Upvotes: 0
Views: 400
Reputation: 66286
Of course, anything a regular Windows app can do, your VSTO addin can do just as easily.
To make an HTTP request, take a look at the HttpClient class
To monitor events on a particular folder use Items.ItemAdd/ItemChange events. The item the that caused the event will be passed to your event handler. Since you can have different types of items in the same folder (e.g. ReportItem and MailItem objects), the parameter is declared as a generic object
and you will need to explicitly interrogate the object type using the as
or is
operators.
To open the folder you are interested in, you can use, for example, Globals.ThisAddin.Application.Session.GetDefaultFolder(olFolderInbox)
.
Upvotes: 1