Share: use C # To write an SqlServer trigger (with source code) for sending emails and text messages to new users)
Thank you for your criticism.
// For SqlServer2005 and later versions// CLR development and testing environment VS2008 + Windows7//
Some netizens asked me if I could send emails asynchronously. I have no problem in the test. Note that the SendCompleted event and SendAsync method are used here.
The Code is as follows. The code is simple and I don't know much about it.
Code
Using System;
Using System. Net. Mail;
Using System. Net. Mime;
Using System. Net;
Using System. Collections;
Namespace ConsoleApplication1
{
Class Program
{
Static void Main (string [] args)
{
Try
{
String file = "attach.txt ";
MailMessage message =
// Introduce the namespace using System. net; using System. net. mail; SmtpClient smtp = new SmtpClient (); // instantiate a SmtpClientsmtp. deliveryMethod = SmtpDeliveryMethod. network; // set the smtp outbound method to Networksmtp. enableSsl =
If you encounter this problem, write it out and share it with you.
This program does not use the javamail API, but directly processes the sent mail according to the requirements of the SMTP protocol. Although it is troublesome, it is helpful to
Original post address: http://www.zu14.cn/2008/12/02/net_sendmail2/
In the previous. net mail article, we talked about the basic aspect. This article is a little more advanced.
Knowledge points:
Embedded image resources in HTML-format emails
Send
Use ASP. NET to build a complete email Sending System
If you want to use ASP for an e-mail sending system, you must first think of components developed by a third party, but this will consume a lot of money. Of course, you can also use the built-in
C # the function of sending emails is found on the internet and socket is also used. The reason why I tried it is that the SMTP server is faulty. Here I use mailmessage and stmp.sohu.com of Sohu. The source code is as follows:
Protected void
Jmail[Download jmail. dll]Step 1: Register jmail
Method 1: windows --> Run --> cmd --> Cd jmail directory --> regsvr32 jmail. dll --> Registration successful
Method 2: Copy jmail. DLL to c: \ windows \ system32, and then enter regsvr32 jmail. dll in
In the second article of the mail series, this article describes how to use mailmessage and smtpclient in the namespace system. net. Mail to send emails.
Using system;
Using system. collections;
Using system. text;
Using system. net;
Using system.
Recently, I am working on the mail sending interface to inform everyone of the problems and solutions I have encountered. I hope it will be helpful to those who know the mail.Some code of the original program is as follows:// Set the sender address,
Recently, a mail-sending class has been written for the project. For your reference.
Code: 1 Imports system. Web. Mail
2
3 Public class texsendmail
4
5
6 public shared sub Sendmail (byval strkey as string, byval htconfig as hashtable)
7
8 dim
Asynchronous mail blocking MVC requests
The problem code is as follows:
Public class emailhelper{Private mailhost = NULL; private httpcontext context; public event sendmailcomplete sendcomplete; private smtpclient client;
Public emailhelper () {
Sendmail: Send mail # region Sendmail: Send mail
/** //
/// Sendmail: send an email
///
///
///
Public void Sendmail ()
{
// Mail Server Settings
Smtpclient MailServer = new smtpclient ();
MailServer. Host = "smtp.gmail.com"; // email sending
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.