ASP.NET combined with COM components Send email A good space http://www.cnblogs.com/hbzxf
When developing an email sender, we often need to use the corresponding components, in fact, there is no need for third-party components (for example, Jmail), which can be used as a function of sending Email.
A file named cdosys.dll can be found in the System 32 subdirectory of the system directory (such as C: / Winnt or C: / Windows), which we can call this COM component via ASP.NET to implement email transmission. CDOSYS is built on the SMTP protocol and the NNTP protocol, and as a component of Windows2000 Server is installed, of course we can also use the Exchange 2000 CDOEx.dll to implement the email mechanism. Since cdosys.dll is automatically embedded in the operating system, do not have to register the corresponding other senders, let's make a send instance.
1. Create a new project file
2, add the cdosys.dll file in the reference system directory, will find two interfaces to use in the reference: CDO, AdoDB
3, add new item SENDMAIL.ASPX, place three Label, three TextBox on its page, and place a button button for the recipient address, theme, and content, and placed a button button.
4. Switch to the code page, create a content
Public void cdosendmail () {type {cdo.message msg = new cdo.message (); msg.from = "Rattlesnake@263.net"; msg.to = this.TextBox1.text.trim (); msg.subject = THISTBOX2.TEXT.TEXTBOX2.TEXT.TEXTBOX2.TEXT.TRIM (); msg.htmlbody = "
" 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; ouelds ["http://schemas.microsoft.com/cdo/configuration/language] .Value = 0x0804; Ofields [" http://schemas.microsoft.com/cdo /configuration/smtpserver"].value="smtp.263.net "; msg.bodypart.charset =" gb2312 "; msg.htmlbodypart.charset =" GB2312 ";Msg.send (); msg = null;} catch (exception err) {throw err;}}
5, add Click event for Button
Private void button1_click (object sender, system.eventargs e) {this.cdosendmail ();
Run the program, then check the mailbox.