You are here:

C#/Scheduled Email

Advertisement


Question
QUESTION: Hi Murat,

I want to send scheduled email in C# without using any event.
Some code that can send mail regularly based on some conditions or base on date/time.

Please Help.
Thanks.

ANSWER: Hi there,

Simply use timer with interval you desire.

See here for mail sending code.

Hope that helps,

Murat

---------- FOLLOW-UP ----------

QUESTION: Thanks For Reply.
I have code to send mail. But question is about timing.
How to create this timer that can automatically fire event and send mail even no one is working on the application.

ANSWER: To clear things up, are we talking about windows forms or web?

---------- FOLLOW-UP ----------

QUESTION: I am talking about WebApplication.

Let me explain. I am making Invoice in my application. Now for unpaid invoices I want that by every 15 days clients with unpaid invoices get email that their payment is remaining. So I want some trigger or timer that can do this.

I hope this will help you to understand.
Thanks.

Answer
Hi,

You have to create a windows service or a desktop app and install on server to achieve this. Another trick could be that (only if you have at least 1 visitor every day) you check last mail sent date in global.asax at session start event and if 15 days past, you send mails and update database. Keep in mind this is generally not preferable as if noone visits your site mails will never be sent.

C#

All Answers


Answers by Expert:


Ask Experts

Volunteer


Murat Mehmet

Expertise

I can help with questions about desktop and web programming in C#, including SOAP, XML, database managing, custom controls, security etc.

Experience

I have been developing web and especially desktop applications in C# and VB.Net for almost 5 years. My programming life has begun with VB6 long time ago, so its about 8 years that I am in this business.

Organizations
Was in R & D for 2 years in a popular Turkish technology website: cyber-warrior.com

Education/Credentials
2011 Computer Engineering graduation in University of Trakia in Turkey.

©2016 About.com. All rights reserved.