You must Sign In to post a response.
  • Category: ASP.NET

    How to send mail after a particular peroid

    Hello all, In the first project i'm doing we have a requirement. am explaining it below.
    first a user registers in our website while registering he will choose a reminder period like 1 month or 2 months etc.. when ever user does not login into our site for that particular period he should get a mail saying that he need to login
    for example if user ramesh registered in our site and chooses 2 months as reminder period. and he logs in on august 1st and did not login for 2 months then he should get a email on October 1st saying that he need to login. I dont know how to approch this problem. please give your ideas.

    thank you
  • #724974
    Hi Sudheer,
    As per your functionality of sending mail for every fixed time frame when the user is not logged in, can be done while checking it everyday at a particular time.
    Lets say the user Ramesh registered in the web site and chooses 2 months as reminder period. Now everyday at a particular time lets say at 00:00, you need to execute a sql script which will check based on the last logic and then reminder period and get the users details who has come in to that criteria.
    So for those users mailid, an email should be sent.
    By this you can achieve and fulfill your requirements.
    let me know if you need more clarifications on this.
    Hope it will be helpful to you.

    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)

  • #724977
    Hello Sudheer.
    A console application can be built which will use the logic to send the reminder through sql agent job scheduler to the users using their email ids. Scheduler can be set once a month or once in a 60 days period of interval to execute the job and send the reminder to the user to fullfill your requirement.
    You need to learn about sceduling jobs using windows/console application.



  • #724978
    Create a Windows service so that you can schedule the time for sending a mail. you can check a database table or set the interval daily or hourly.

    Use the below code to send email

    protected void btnSubmit_Click(object sender, EventArgs e)
    MailAddress SendFrom = new MailAddress(txtFrom.Text);
    MailAddress SendTo = new MailAddress(txtTo.Text);

    MailMessage MyMessage = new MailMessage(SendFrom, SendTo);

    MyMessage.Subject = txtSubject.Text;
    MyMessage.Body = txtBody.Text;

    Attachment attachFile = new Attachment(txtAttachmentPath.Text);

    SmtpClient emailClient = new SmtpClient(txtSMTPServer.Text);

    litStatus.Text = "Message Sent";
    catch (Exception ex)

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #724992
    if you are using SQL Server as database. then Schedule a Job that runs on daily. You have to check it regularly for in active users.

    Simple solution is schedule a job and send mails regularly

    Refer those URLS also

    Hemanth G

  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.