使用C#安排电子邮件 [英] Schedule emails using C#

查看:127
本文介绍了使用C#安排电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够生成一个C#程序,该程序可以安排在设定的时间运行,并可以让该程序读取文件并根据关键信息安排电子邮件,请提出任何建议.

我尝试过的事情:

一切都还没有开始,并试图编写一个程序来安排家​​庭使用的电子邮件

I would like to be able to produce a c# program that I can schedule to run at a set time and for that program to read a file and based on key information schedule emails, any suggest please.

What I have tried:

nothing yet just beginning to look and trying to write a program to schedule emails for home use

推荐答案

您不能编写在特定时间运行的程序-当时正在运行,或者没有运行.您可以告诉操作系统在特定时间运行它(并且假设计算机已打开电源并且可以正常工作)它将执行该操作.
对于Windows,您可以使用任务计划程序:任务计划程序( Windows) [ ^ ]

另一种方法是在计算机通过启动"启动时运行该应用程序,并每隔六十秒左右检查一次是否该做某事.

无论哪种方式,您都需要编写代码来发送电子邮件,并告诉操作系统何时运行它.这可能对电子邮件部分有所帮助:在以下位置发送电子邮件带有或不带有附件的C#:通用例程. [
You can''t "write a program to run at a specific time" - it''s either running at the time, or it isn''t. You can tell you operating system to run it at a specific time and (assuming the computer is powered on and working) it will do it.
For Windows, you would use the Task Scheduler: Task Scheduler (Windows)[^]

The other approach is to run the app when the computer starts via Startup, and have it check every sixty seconds or so if it is time to do something.

Either way, you need to write the code to send your emails, and tell the operating system when to run it. This may help with the email part: Sending an Email in C# with or without attachments: generic routine.[^]


上面OG所说的是正确的

-但是您可以使用"Topshelf"编写"Win32服务"(一直在运行),并通过将Quartz.Net添加到服务中来计划电子邮件发送过程-这样,您可以计划(例如),按时间间隔-每15分钟",或使用"cron"类型规范,或混合使用

那就是我要开始的地方
What OG said above is correct

- but you could write a ''Win32 Service'' (which is running all the time), using say ''Topshelf'', and schedule your email send procedure by adding Quartz.Net to the service - that way, you can schedule (for example) by interval - ''every 15 minutes'', or using ''cron'' type specifications , or a mixture thereof

Thats where I''d start


这篇关于使用C#安排电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆