Answered by:
How to send an Email to a user after a specific time passes? ASP.NET

Question
-
User102575017 posted
Hello everyone,
I have a table of users in my database. Each time the user logs in, a column that is called "UserActivity" type DATETIME is updated in the table to the current date that the user logged in. Now, what I want is, if the user did not log in for 15 days (half a month), he would receive an Email informing him to be active on the website.
I asked this question before on this board, but the thing is that I wanted to send an email using phpMyAdmin which, after searching, is not possible in my case. I saw that I can use Windows Service or Quartz or Task Scheduler in order to achieve what I want. But unfortunately, I have no idea of using them.
Thank you for reading.
Sincerely,
Majid Abu Rmelah.
Wednesday, May 15, 2019 5:48 PM
Answers
-
User665608656 posted
Hi Majid Abu Rmelah,
Based on your question, I recommend that you use Task Scheduler for operation.
You can first create an exe program, which writes the logical information you need to execute the email: read the table in the database that records user login information, and then read the date of the "User Activity" column to compare with the current date, to see if it has not logged in for more than 15 days, and if it exceeds, send the email.Step 1: Search locally on your computer and open the Task Scheduler software.
Step 2: Select Create Basic Task in the right column.
Step 3: Create your Task Schedule name and description, and click Next.
Step 4: Select how often you want to execute Task in Trigger and click Next.
Step 5: Depending on the frequency of your choice, fill in more detailed information.For example, you choose Daily.,then you need to determine if it is executed from the current moment, and every few days, click Next.
Step 6: Choose a form of task you need to perform. You could choose the first Start a program and click Next.
Step 7: Click Browse, select the location of your exe file, add parameters and set the folder for program/script startup if necessary, and click Next.
Step 8: Check all the information you filled in before, click Finish, and you will create your Task Schedule successfully and start it.
You can also refer to this link: https://docs.microsoft.com/en-us/windows/desktop/taskschd/daily-trigger-example--scripting-Best Regards,
YongQing.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, May 16, 2019 6:25 AM -
User665608656 posted
Hi Majid Abu Rmelah,
Your idea is right, but you could not use the .cs file to run in Task Scheduler.
Because .cs file is just a document with code in it, you need to create an application that can be executed by opening it.
You can refer to this link for more information: https://docs.microsoft.com/en-au/windows/desktop/api/taskschd/ne-taskschd-_task_action_type
Such as .exe application, you could put your code idea into .exe application to run Task Scheduler.
You can refer to this link how to create an exe application:
Best Regards,
YongQing.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, May 17, 2019 8:24 AM
All replies
-
User665608656 posted
Hi Majid Abu Rmelah,
Based on your question, I recommend that you use Task Scheduler for operation.
You can first create an exe program, which writes the logical information you need to execute the email: read the table in the database that records user login information, and then read the date of the "User Activity" column to compare with the current date, to see if it has not logged in for more than 15 days, and if it exceeds, send the email.Step 1: Search locally on your computer and open the Task Scheduler software.
Step 2: Select Create Basic Task in the right column.
Step 3: Create your Task Schedule name and description, and click Next.
Step 4: Select how often you want to execute Task in Trigger and click Next.
Step 5: Depending on the frequency of your choice, fill in more detailed information.For example, you choose Daily.,then you need to determine if it is executed from the current moment, and every few days, click Next.
Step 6: Choose a form of task you need to perform. You could choose the first Start a program and click Next.
Step 7: Click Browse, select the location of your exe file, add parameters and set the folder for program/script startup if necessary, and click Next.
Step 8: Check all the information you filled in before, click Finish, and you will create your Task Schedule successfully and start it.
You can also refer to this link: https://docs.microsoft.com/en-us/windows/desktop/taskschd/daily-trigger-example--scripting-Best Regards,
YongQing.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, May 16, 2019 6:25 AM -
User102575017 posted
Hello Yongqing Yu,
Thank you for putting the time and effort to help me with this, I really appreciate that.
I did exactly what you told me to do and I have created my task successfully.
In step 7, I have chosen a .cs file from my website folder that has the code to check the activity of the user and send the mail if 15 days passed.
I would like to ask, when the Task Scheduler runs the basic task again daily, would it run the code that I have chosen as if I ran it by myself?
Hope to hear from you soon and thank you again.
Sincerely,
Majid Abu Rmelah.
Thursday, May 16, 2019 10:32 AM -
User665608656 posted
Hi Majid Abu Rmelah,
Your idea is right, but you could not use the .cs file to run in Task Scheduler.
Because .cs file is just a document with code in it, you need to create an application that can be executed by opening it.
You can refer to this link for more information: https://docs.microsoft.com/en-au/windows/desktop/api/taskschd/ne-taskschd-_task_action_type
Such as .exe application, you could put your code idea into .exe application to run Task Scheduler.
You can refer to this link how to create an exe application:
Best Regards,
YongQing.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, May 17, 2019 8:24 AM -
User102575017 posted
Worked absolutely perfect!
I don't how to thank you, You helped me to do something that I thought is impossible to do.
I really appreciate your help, may Allah bless you and jazakallah khair.
Sincerely,
Majid Abu Rmelah.
Friday, May 17, 2019 2:05 PM -
User465502865 posted
Thanks for help!Friday, May 17, 2019 2:58 PM