How to implement a windows service??

brazilnut52

Newcomer
Joined
Feb 7, 2003
Messages
16
Hello. I am new to VB .NET. I have been given a project that will require a windows service. I would like to create a program that runs in the background all the time. The actuall functionality is triggered when an email is received in the inbox of my outlook. The program basically checks the email... if it is from the desired sender it processes the zip file associated. At this time, I need general direction on how to implement a program that runs constantly. I think I can figure out the file processing myself.

Thanks,
brazilnut
 
It doesn't sound like you need a Windows Service exactly because you want it to pull out of your Outlook? Will the program actually interact with Outlook, or do you really mean it will connect to Exchange and pull the emails from there? If it has to interact with the Outlook program itself, then a Windows Service is probably not the best option since the user will have to be logged in and running Outlook. Do you mean it will come from Exchange?
 
Good question. Ideally, this service will run at all times.. even when the user is not logged in. Therefore anytime the service is on and my inbox receives an email, the service is triggered. So I guess I stated my question incorrectly earlier. I actually need the program to interact with the email server. It should be triggered when an email comes to my inbox on the email server.

Once I get this figured out I can do more with the actual mail:
1) I will need to unzip attachments
2) parse certain data out of the txt body of the email.

Here is the run down.... I get two emails from a company. One email has a zip file that I need to download... extract... then rename and move files on the local system. The other email contains a link to a downloadable pdf file. Normally I would cut and paste the link in a browser window then save the pdf to my local disk. I would like this process to be performed by the application as well. If I could get this done with the service, it would be awesome. I could save about 2+ hrs of work a day.

thanks for the reply,
brazilnut
 
I agree that a Service is not what you want to use for this. A Service is designed for background tasks that don't require a user to even be logged into the system at all (it could be sitting at the login prompt and the service would work). Also, a Service typically runs under the System account and therefore is "userless" and thus has no Domain privileges. You can run a service under a domain account, but I don't think this is what you want to do.

Since your whole project revolves around Outlook. Why not use Outlook to accomplish the task? To me it sounds like you will have a user logged into the workstation with Outlook open so why not take advantage of the Outlook Rules?

I would check out the "Custom Action" that Outlook has for processing Rules. It allows you to write your own DLL and have Outlook link to that DLL to run your custom action. As to wether you can do this with .NET is questionable (no personal exp here).

You might also check out the "start application", as you could possibly have it launch a program that would then link to Outlook and do it's processing from there (either thru automation or a direct exchange connection).

Since your using the Rules engine you can have the rule fire when a new message arrives and add additional standard criteria like who it's from or a phrase in the email itself.
 
Back
Top