2
0
I am looking to make a Python script that runs on whenever an email is received. In Windows Task Scheduler, I can set up a trigger for "On an event", using the Application log and "Outlook" as the source. However, I do not know what the Event ID for a new incoming email is. I've been Googling around for a while and haven't found anything likely because I don't know the correct search terms. Perhaps someone here knows where to look, or better yet, the answer directly?
Not sure if it matters, but I'm running Windows 7, 64-bit with Outlook 2010. Thanks in advance
EDIT: I'm assuming that there is one single event ID that is generated when an email is recieved. That ID (or where to find it) is what I'm looking for. If this is not the case, and there is no single ID which corresponds to an incoming email, then any work around y'all can think of would be great
EDIT: To avoid the XY problem, the goal here is to figure out a way to have a python script run upon receiving an e-mail..
Another, hopefully better, Edit: There are two main things I'm trying to do:
I have a Python script which handles a form which my entire office uses (~30 people). This form sends emails to various people around the office. It would be nice if it didn't just blindly send emails into the ether, but rather received feedback. Things such as acknowledgement that the email was properly sent, and then read. This is goal 1.
Goal 2 is a bit more simple. Thanks to the wonderful regulations in my industry, we have to keep an insane amount of records for certain projects. This includes emails. So I would like to set up a list of clients/projects which need this treatment, so that when such emails are received, they can automatically be stored (probably as a pdf) or printed.
Hopefully this helps
I think you should be able to set up a rule in Outlook so that when an email is received, it runs a script. I'm not 100% sure what scripts you can run (I assume you're probably limited to VB) but you can probably create a script that writes a custom event to the log. You may even be able to create a script that talks directly to your python script. – Miles Hayler – 2014-01-08T23:33:47.060
Although the Rules Wizard refers to the custom code as "script," you must create the code in Outlook Visual Basic for Applications, not in Microsoft Visual Basic Scripting Edition (VBScript) or other scripting languages such as Microsoft JScript. Also, Outlook Visual Basic for Applications is not designed to be deployed, so deployment of this custom code requires manual configuration on each user's computer. Source: http://support.microsoft.com/kb/306108
– Miles Hayler – 2014-01-08T23:35:19.180@MilesHayler There's no direct trigger for a received email, only the method I describe above. As for running the script, I can definitely directly run python – wnnmaw – 2014-01-08T23:37:09.830
@MilesHayler I understand the confusion, I'm working with windows task scheduler, which is independent of Outlook – wnnmaw – 2014-01-08T23:38:09.897
1Well you can perhaps handle it through VBA macro in outlook itself. VBA can do a lot of things outside domain of its parent application as well. Why are you specifically looking for external script? – tumchaaditya – 2014-01-09T17:16:25.650
There are a couple things in looking to do, the biggest is to get feedback that emails are sent correctly by another python script. Also, automatic printing /filing based on the sender would be nice – wnnmaw – 2014-01-09T18:01:29.067
I meant what @tumchaaditya said. You can probably write events directly to the event log with a script. – Miles Hayler – 2014-01-12T00:40:06.003
@MilesHayler How would I do such a thing? – wnnmaw – 2014-01-13T14:19:09.137
Why are you trying to do this through task scheduler? A new message in Outlook doesn't normally generate any events that can be captured in task manager. What are you really trying to do?
– Zoredache – 2014-01-13T17:39:01.270@Zoredache, Thanks for pointing that out, see my edit. I defaulted to task scheduler because I didn't know there were alternatives – wnnmaw – 2014-01-13T17:46:31.840
Something like http://stackoverflow.com/questions/11263483/how-do-i-trigger-a-macro-to-run-after-a-new-mail-is-received-in-outlook perhaps? That just builds the VBA event. Then maybe toss in this for launching your python app if you don't want to do your work in VBA. http://stackoverflow.com/questions/6767445/how-to-launch-one-other-program-with-vba-code
– Zoredache – 2014-01-13T17:49:06.5871There's definitely an ID for every mail, it's a very long string and is written in different formats. This has nothing to to with an Event ID from the event viewer logs. What is your mail backend, Exchange server? Have you looked at its APIs? Show some things that you have tried, what information did you manage to receive? A complication may also be having to distinguish new/modified events. – Jan Doggen – 2014-01-14T14:42:44.603
And this may turn out to be a programming question, in which case it has to move to StackExchange. – Jan Doggen – 2014-01-14T14:44:24.517
@JanDoggen, Once I figure out how to trigger my script, I can do everything else. Unfortunately, I have no progress to show what I've done aside from what I've already written. And yes, I'm pretty sure this is on an Exchange server – wnnmaw – 2014-01-14T14:48:40.440
And have you looked at the Exchange APIS like EWS? IIRC they have notifications. No idea though how hard that would be to handle from Python. Advantage is that it would take Outlook out of the loop. – Jan Doggen – 2014-01-14T15:05:55.787
BTW I think your second edit is incomplete. You want to do something with that mail. – Jan Doggen – 2014-01-14T15:07:09.060
Frist comment: I haven't looked into those. Right now I'm looking into writting a python script which an implement Outlook rules as per Oliver's answer. Second comment: Yes, I know how to do that processing once I get into a Python – wnnmaw – 2014-01-14T15:16:43.597
1If the form sends emails within your company, then why even assume it wasn't delivered? Either way, if it was delivered would be most optimally checked on your mail exchange server, which knows when it places the email into the users mailbox. Solutions in regards to archiving email would also best be implemented on the mail exchange server in my opinion. – Der Hochstapler – 2014-01-14T15:43:31.943