1

I have developed a website and want to send an auto-generated mail to new user's regarding the website on every 3rd day from their registration day.

I don't know is it possible or not. If it is possible, can I know how ?

Thanks for the help..

Jay Patel
  • 95
  • 1
  • 12
  • Yes, it is possible. There are plenty of ways to achieve this. – Rostech Jul 27 '17 at 06:11
  • When you say every third day, do you mean each user gets email on 3rd day, 6th day, 9th day etc or just once on 3rd day? – Jonathan Willcock Jul 27 '17 at 06:14
  • @Rostech Can I know the easiest or the best way to do that ? – Jay Patel Jul 27 '17 at 06:16
  • @JonathanWillcock Yes, It's like that only. On 3rd day, 6th day, 9th day, etc.. – Jay Patel Jul 27 '17 at 06:17
  • @JayPatel this is the easiest but not the best way. [Click me](https://www.codeproject.com/Articles/49996/Schedule-Email-Through-ASP-NET-or-Schedule-Tasks-U) – Rostech Jul 27 '17 at 06:19
  • 1
    @JayPatel, you can also look at this [question](https://stackoverflow.com/questions/1350634/scheduled-mail-in-asp-net) – Rostech Jul 27 '17 at 06:21
  • @Rostech I am confused now. For what I should go for ? Windows Service or Application Start ? Please guide me which is the suitable one. – Jay Patel Jul 27 '17 at 06:28
  • @JayPatel, oh, I'm sorry I've got you confused. I would go with windows service. – Rostech Jul 27 '17 at 08:00
  • Windows service for once a day job is a bit overkill . For windows I suggest Task Scheduler. You can create a windowless app which is called by the scheduler rather than having a service with a long timer running all the time. – Jonathan Willcock Jul 28 '17 at 16:12
  • @Rostech As per your preference I done all the things and edited according to my requirement and its working great in localhost but when I upload the Global.asax file on sever my website shows runtime error. Is their any solution of this ?? – Jay Patel Aug 01 '17 at 04:53
  • @Rostech Sorry.. Its my mistake in uploading files. Auto-mail is working awesome. Thanks for all you help. – Jay Patel Aug 01 '17 at 05:19

2 Answers2

0

To get every day the users who are 3,6,9 days old etc. you need to run daily a SQL statement along the lines of (this is T-SQL syntax):

SELECT UserName, EMail FROM Users WHERE (cast(RegistrationDate as int) - cast (GETDATE() as int)) % 3 = 0 AND RegistrationDate > GETDATE()

As to which method to use for your daily task, as we say in English "you pay your money and you take your choice". However, I do not think it a good idea to have a timer on your website just to do a once a day job. Better would be something like Task Scheduler on Windows or cron on Unix/Linux.

Jonathan Willcock
  • 5,012
  • 3
  • 20
  • 31
0

Using C#

  1. Write a console application to get the dataset of users whose registered date is meeting 3 days bucket & send email using smtp
  2. Build & get .exe file to configure in Task scheduler on your required schedule

Refer this

Using SQL

  1. Use sp_send_dbmail in SQL server to distribute email

SO thread