ASP.NET with COM components Send an Email
ASP.NET with COM components Send an Email
A good space
Http://www.cnblogs.com/hbzxf
E-mail sent in the development process, we often need to use the corresponding component, in fact does not require third-party components (such as: Jmail) Business as usual can be sent to Email functions.
In the system directory (such as c: \ winnt or c: \ windows) system32 can be found in a subdirectory name cdosys.dll document, and we can call this ASP.NET COM components to achieve Email sender. Cdosys Construction in the SMTP and NNTP agreement on the agreement, and as Windows2000 Server components are installed, of course, we can also use Exchange2000 cdoex.dll to achieve in the email system. As cdosys.dll automatically embedded in the operating system, and so we do not have to register again sent the corresponding other procedures, the following example we do a send.
1, a new project document
2, add quote system directory under the cdosys.dll documents found in the application will use to add the two interfaces: CDO, ADODB
3, and add new documents SendMail.aspx in its place three pages Label, three Textbox, role for the recipient address, the theme, content, Button placed a button.
4, switch to code page, create a content
Public void CDOsendmail ()
(
Try
(
CDO.Message Msg = new CDO.Message ();
Msg.From = "rattlesnake@263.net";
Msg.To = this.TextBox1.Text.Trim ();
Msg.Subject = this.TextBox2.Text.Trim ();
Msg.HTMLBody = "<html> <body>" + this.TextBox3.Text
+ "</ Body> </ html>";
CDO.IConfiguration Config = Msg.Configuration;
ADODB.Fields oFields = Config.Fields;
OFields [ "http://schemas.microsoft.com/cdo/configuration/sendusing"]. Value = 2;
OFields [ "http://schemas.microsoft.com/cdo/configuration/sendusername"]. Value = "rattlesnake";
OFields [ "http://schemas.microsoft.com/cdo/configuration/sendpassword"]. Value = "pass";
OFields [ "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"]. Value = 1;
OFields [ "http://schemas.microsoft.com/cdo/configuration/languagecode"]. Value = 0×0804;
OFields [ "http://schemas.microsoft.com/cdo/configuration/smtpserver"]. Value = "smtp.263.net";
OFields.Update ();
Msg.BodyPart.Charset = "gb2312";
Msg.HTMLBodyPart.Charset = "gb2312";
Msg.Send ();
Msg = null;
)
Catch (Exception err)
(
Throw err;
)
)
5, Click event for the Button added
Private void Button1_Click (object sender, System.EventArgs e)
(
This.CDOsendmail ();
)
Operating procedures, and check E-mail can be.
Tags: ASP.net, com, components, email








0 Comments to “ASP.NET with COM components Send an Email”
No Comments. Send your comment.
Leave a Reply
You must be logged in to post a comment.