C # use the windows service to send emails,

Source: Internet
Author: User

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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.