C#使用windows服务发送邮件
作者:Brambling 时间:2022-05-31 11:54:55
最近做了一个使用 C# 写了一个发送邮件的windows 服务,在这里记录一下。
首先使用 Visual Studio 2015 创建一个 windows 服务项目。
然后在设计器上面右击添加安装程序。如下图。
安装好后,选择安装程序设计界面,选择服务和安装程序右击选择属性修改一些属性值。
PS:如果不给服务添加安装程序,后面是没法把服务安装至 windows 系统里的。
在数据库创建一个表,用于存储需要发送的邮件信息。
create table MainInfo
(
MainInfoID int not null identity(1,1) primary key,
Mail_To nvarchar(64) not null, -- 收件人邮箱
Title nvarchar(128) not null, -- 邮件标题
Content nvarchar(max) null, -- 邮件内容
Mode int not null default(0), -- 发送方式,0为默认发送,1为抄送,2为密送
SendState int not null default(0), -- 发送状态,0为未发送,1为发送成功,2为发送失败
IsTimer int not null default(0), -- 0为即时发送,1为定时发送
SendTime nvarchar(64) null -- 定时发送的时间
)
明天继续。
标签:C#,windows,邮件
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Hibernate中Session增删改查操作代码详解
2022-12-25 17:14:22
![](https://img.aspxhome.com/file/2023/6/62826_0s.jpg)
mybatis新手快速入门以及一些错误汇总
2023-01-25 13:01:14
![](https://img.aspxhome.com/file/2023/8/63798_0s.png)
springboot项目中jackson-序列化-处理 NULL教程
2022-11-03 14:36:21
使用Feign动态设置header和原理分析
2021-07-11 10:30:46
![](https://img.aspxhome.com/file/2023/6/113426_0s.jpg)
IntelliJ IDEA中properties文件显示乱码问题的解决办法
2021-09-08 04:59:03
![](https://img.aspxhome.com/file/2023/4/69884_0s.png)
Winform让DataGridView左侧显示图片
2021-09-24 03:50:38
![](https://img.aspxhome.com/file/2023/3/78173_0s.jpg)
Java实现过滤掉map集合中key或value为空的值示例
2021-05-25 10:26:17
Spring事务传播中嵌套调用实现方法详细介绍
2021-08-31 22:34:24
![](https://img.aspxhome.com/file/2023/3/69733_0s.png)
Java实战个人博客系统的实现流程
2023-04-12 02:32:44
![](https://img.aspxhome.com/file/2023/4/103834_0s.png)
C#特性 扩展方法
2023-01-15 03:45:15
![](https://img.aspxhome.com/file/2023/7/108767_0s.jpg)
SpringBoot整合Mybatis自定义拦截器不起作用的处理方案
2023-03-19 04:35:14
![](https://img.aspxhome.com/file/2023/7/77937_0s.png)
Unity实现滑动更换界面效果
2021-10-06 19:56:40
![](https://img.aspxhome.com/file/2023/6/84466_0s.jpg)
浅谈Java8 判空新写法
2023-06-21 15:55:08
![](https://img.aspxhome.com/file/2023/2/75712_0s.jpg)
Java读取properties配置文件的8种方式汇总
2022-05-03 17:11:34
![](https://img.aspxhome.com/file/2023/9/96079_0s.png)
Android采取ContentObserver方式自动获取验证码
2023-07-31 16:20:48
java面试常见模式问题---单例模式
2022-11-29 09:12:28
Java shiro安全框架使用介绍
2023-07-09 05:24:35
![](https://img.aspxhome.com/file/2023/3/69653_0s.png)
Java实现批量向mysql写入数据的方法
2023-11-05 20:51:21
Android中使用Bitmap类将矩形图片转为圆形的方法
2022-01-04 18:47:40
![](https://img.aspxhome.com/file/2023/9/110759_0s.jpg)
Android自定义带圆点的半圆形进度条
2023-08-05 07:47:15
![](https://img.aspxhome.com/file/2023/0/86750_0s.png)