Click here to Skip to main content
15,908,166 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need a code in c# of reminder generation, i don't want to implement reminders through windows service, i just want that when due date is 5 days ahead i want to send a reminder to the number of users via email in c# asp.NEt, please guide me or send me a useful code in this regard
Posted
Comments
Parwej Ahamad 22-Jun-11 11:50am    
Dear, I don't think so would be best way to implement on asp.net. Either you have to create a Windows Service OR Create SQL Server Jobs would be best way to implement this.
Sergey Alexandrovich Kryukov 22-Jun-11 12:00pm    
I would agree with you, but may be reminder is just one feature of the Web application OP needs? I'm not sure. Anyway, there is an option to write just e-mail application and start it using scheduling service.

Anyway, please see my solution -- good for different options.
--SA
Parwej Ahamad 22-Jun-11 12:05pm    
Thanks for your suggestion and I agree with you. MS Task Scheduler is really new for me too and I will look into.

Thanks SA for sharing your great experience with us.
Sergey Alexandrovich Kryukov 22-Jun-11 12:09pm    
You're very welcome. Thank you for your note above and your contribution helping me to write a more relevant solution, credited.
--SA

You can use Microsoft Task Scheduler for this purpose.

See:
http://msdn.microsoft.com/en-us/library/aa383614(v=VS.85).aspx[^],
http://msdn.microsoft.com/en-us/library/aa383608(v=VS.85).aspx[^].

[EDIT]
As Parwej Ahamad pointed out, you may not need ASP.NET application for this purpose. You might create a simple application just sending e-mail. You can start this application using available Scheduler service without programming, just using available application AT.EXE or SchTasks.EXE.

See:

AT.EXE:
http://en.wikipedia.org/wiki/At_(Windows)[^],
http://technet.microsoft.com/en-us/library/bb490866.aspx[^].

SchTasks.EXE:
http://en.wikipedia.org/wiki/Schtasks[^],
http://technet.microsoft.com/en-us/library/bb490996.aspx[^].

—SA
 
Share this answer
 
v2
Comments
thatraja 22-Jun-11 12:46pm    
Good bunch, 5!
Sergey Alexandrovich Kryukov 22-Jun-11 12:51pm    
Thank you, Raja.
--SA
I think there is a simpler way to handle this using workflows.

here is how it can be done..

1. Create a sequential workflow with a Delay activity and another activity to send e-mail as needed by your app.
2. Place this inside a while activity with condition set to True
3. In the global.asax.cs file add floowing code for Application_Start event

System.Workflow.Runtime.WorkflowRuntime workflowRuntime = new System.Workflow.Runtime.WorkflowRuntime();

System.Workflow.Runtime.Hosting.ManualWorkflowSchedulerService manualService =
    new System.Workflow.Runtime.Hosting.ManualWorkflowSchedulerService();
workflowRuntime.AddService(manualService);

workflowRuntime.StartRuntime();

Application["WorkflowRuntime"] = workflowRuntime;

ManualWorkflowSchedulerService manualScheduler =
    workflowRuntime.GetService(typeof(ManualWorkflowSchedulerService))
    as ManualWorkflowSchedulerService;

//WorkflowInvoker.Invoke(new Workflow1());
WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication1.Workflow1));

instance.Start();
manualScheduler.RunWorkflow(instance.InstanceId);



in Application_End event add following code:
    System.Workflow.Runtime.WorkflowRuntime workflowRuntime =
Application["WorkflowRuntime"] as System.Workflow.Runtime.WorkflowRuntime;
    workflowRuntime.StopRuntime();


Assuming Workflow1 is the name of the workflow you have created.

This would be with following advantages
1. Light wait workflow and would not cause any overhead
2. Restarting the asp.net applciaiton would restart the workflow service as well.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900