Search code examples
c#.networkflow-foundation

Calling a function periodically c#


I am sending mails from my codes, for some activities.

But some mails may fail due to some or other reason.

I am keeping details of all such failed mails in a table.

Now my plan is to periodically check that table and resend mails if the table contain failed mails.

Or in other words,I want to call a method SentFailedMails() in every 12 hours.

How can I do this is c#

My application is a WCF service,Hosted on IIS


Solution

  • Create a very simple console application that do the task (move your SentFailedMails() method to this application and execute it on run).

    Place the exe file for the console application in a folder of your server.

    Use Windows Task Scheduler to schedule the exe file execution for every 12 hours or on any specific time.