本文介绍了即使关闭页面也要调用C#函数.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助,
亲爱的朋友,我建立了一个网站,希望在午夜时分,即使没有人登录,也要每天向所有会员发送保险提醒邮件.

因此没有人调用提醒功能.应该在每个午夜定期进行.

预先感谢,
Rajkumar

please help,
dear friends i have developed a website in which i want to send a insurance reminders Email every day to all members , in the midnight even when no one is logged in the website.

so no one is calling the reminder function. it should be done periodically at every midnight.

Thanks in advance,
Rajkumar

推荐答案

protected void SendMail()
{
    // Gmail Address from where you send the mail
    var fromAddress = "[email protected]";
    // any address where the email will be sending
    var toAddress = YourEmail.Text.ToString();
    //Password of your gmail address
    const string fromPassword = "Password";
     // Passing the values and make a email formate to display
    string subject = YourSubject.Text.ToString();
    string body = "From: " + YourName.Text + "\n";
    body += "Email: " + YourEmail.Text + "\n";
    body += "Subject: " + YourSubject.Text + "\n";
    body += "Question: \n" + Comments.Text + "\n";
    // smtp settings
    var smtp = new System.Net.Mail.SmtpClient();
    {
        smtp.Host = "smtp.gmail.com"; // provide your smtpserver
        smtp.Port = 587;
        smtp.EnableSsl = true;
        smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
// provide your stmp server credentials
        smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
        smtp.Timeout = 20000;
    }
    // Passing values to smtp object
    smtp.Send(fromAddress, toAddress, subject, body);
}


4.全面测试.
5.以发布模式进行构建.
6.从bin文件夹中获取exe并将其添加到服务器的Schedule TASK中
7.如果您不知道该怎么做,请参阅:.. 安排任务 [ ^ ]

8.如果发现它对您有用,请不要忘记将其标记为答案


4. Test it throughly.
5. build it in release mode.
6. Take the exe from your bin folder and add that into Schedule TASK of your server
7. If you dont know how to do it refer this : ..Schedule a Task[^]

8. Dont forget to mark it as answer if you have found it working for you


这篇关于即使关闭页面也要调用C#函数.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 06:43