The email sending program web. Mail under. NET 2.0

Source: Internet
Author: User
Tags mailmessage

 

1 Using System;
2 Using System. Data;
3 Using System. configuration;
4 Using System. collections;
5 Using System. Web;
6 Using System. Web. Security;
7 Using System. Web. UI;
8 Using System. Web. UI. webcontrols;
9 Using System. Web. UI. webcontrols. webparts;
10 Using System. Web. UI. htmlcontrols;
11 Using System. Web. mail;
12
13 Public   Class Sendmail
14 {
15 String Tb_from;
16 String Tb_to;
17 String Tb_mailbody;
18 String Tb_smtpserver;
19 String Tb_body;
20 String Tb_sub;
21 Public Sendmail ( String To, String Body, String Sub)
22 {
23Tb_to=To. Trim ();
24Tb_body=Body. Trim ();
25Tb_sub=Sub. Trim ();
26}
27
28 Public   Void Sengmill_net ()
29 {
30 Tb_from =   " Xxxx@21cn.com " ;
31 Tb_mailbody = Tb_body;
32 Tb_smtpserver =   " Smtp.21cn.com " ;
33 System. Web. Mail. mailmessage mailmsg =   New System. Web. Mail. mailmessage ();
34 Mailmsg. From = Tb_from;
35 Mailmsg. = Tb_to;
36 Mailmsg. Body = Tb_mailbody;
37 Mailmsg. Subject = Tb_sub;
38 Mailmsg. Fields. Add ( " Http://schemas.microsoft.com/cdo/configuration/smtpauthenticate " , " 1 " );
39 // Whether verification is required. Generally, verification is required.
40 Mailmsg. Fields. Add ( " Http://schemas.microsoft.com/cdo/configuration/sendusername " , " XXXXX " );
41 // User name in your mailbox
42 Mailmsg. Fields. Add ( " Http://schemas.microsoft.com/cdo/configuration/sendpassword " , " XXXXX " );
43 // Password of your mailbox
44 System. Web. Mail. smtpmail. smtpserver = Tb_smtpserver;
45 System. Web. Mail. smtpmail. Send (mailmsg );
46 }
47 }
48
49 Public Partial Class Bank: system. Web. UI. Page
50 {
51 Protected   Void Page_load ( Object Sender, eventargs E)
52 {
53
54}
55 Protected   Void Btnsend_click ( Object Sender, eventargs E)
56
57 {
58 /**/ ////Call code
59 Sendmail t = New Sendmail (xxx@xxx.com, " Text Content " , " Title content " );
60 T. sengmill_net ();
61 }
62 }

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.