Easy e-mail with C #: HY. Mail a simple, easy-to-use, flexible message tool Library

Source: Internet
Author: User
Tags system log

First, the original intention of developing Hy.mail

There are a lot of mature and good mail repositories available on NuGet or GitHub, but the use you've found is not concise or inappropriate for my usage scenarios.

My scenario is to develop scenarios (such as system notifications, operations notifications) rather than business scenarios (sending mail to customers, HY. Mail also applies to this scenario).

Need to be able to be flexible and concise calls, need to preset some mail information.

For example, system operation: Need to do the system log mail notification, the general recipient, recipients, cc people are preselected settings. Then we need to pre-set n MailSender, and then call the corresponding MailSender as needed to send the message body, without having to set the sender's password recipient before the call.

Second, HY. Mail uses

Hy. Mail is further encapsulated with System.Net.Mail, lightweight, concise, thread-safe, optimized for multithreading.

Define your own sender (the class library is already pre-Qqmailsender):

    Public classMymailsender:mailsender {Private Const stringHOST ="SMTP. Xx.com"; Private Const intPORT = -;  PublicMymailsender (stringMailAddress,stringPasswordstringto="",stringCc="",stringtitle="")        : Base(HOST, PORT, MailAddress, password,to,cc) {}
}

Usage:

var New Mymailsender ("[email protected]" "xxxxxxxxxxxxxxxx");            Sender.send ("[email protected] " " test mail " " message body ");

By defining sender, you can flexibly define different types of mailboxes: QQ, 163, Alibaba Mail. The default recipient can also be preset via sender, as follows:

  Public Static classMymailfactory { Public Static stringTest =string.        Empty;  Public StaticMymailsender Toxxmailsender =NewMymailsender ("[email protected]","pwd","[email protected]");  Public StaticMymailsender Toyymailsender =NewMymailsender ("[email protected]","pwd","[email protected]"); } MyMailFactory.ToXXMailSender.Send ("title","content")

This allows for very flexible and concise invocation in different scenarios.

NuGet installation: Install-package HY. Mail

GitHub Address: Https://github.com/HYDevTools/HYMail-CSharp

Easy e-mail with C #: HY. Mail a simple, easy-to-use, flexible message tool Library

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.