C # use the windows service to send emails,
Recently I made a windows service that uses C # To write an email. Here I will record it.
First, use Visual Studio 2015 to create a windows service project.
Right-click the designer and add the installer. For example.
After installation, select the installation program design interface, select Services and installation programs, and right-click Select properties to modify some property values.
PS: if you do not add an installer to the service, you cannot install the service in windows.
Create a table in the database to store the mail information to be sent.
Create table MainInfo (MainInfoID int not null identity (128) primary key, Mail_To nvarchar (64) not null, -- recipient mailbox Title nvarchar () not null, -- mail title Content nvarchar (max) null, -- mail Content Mode int not null default (0), -- sending method, 0 is the default sending, 1 is CC, 2: Send SendState int not null default (0), -- send status, 0 is not sent, 1 is sent successfully, 2 is failed IsTimer int not null default (0 ), -- 0 indicates instant sending, 1 indicates timed SendTime nvarchar (64) null -- timed sending time)
Continue tomorrow...