在来个发Mail的方法

 1 private   void  Send_Click( object  sender, System.EventArgs e)
 2          {
 3            MailMessage objMail=new MailMessage();
 4            objMail.From=this.form.Text;
 5            objMail.To=this.to.Text;
 6            objMail.Cc=this.cc.Text;
 7            objMail.Bcc=this.bcc.Text;
 8            objMail.Subject=this.subject.Text;
 9            objMail.Body=this.text.Text;
10            objMail.BodyFormat=MailFormat.Html;
11            objMail.BodyEncoding=System.Text.Encoding.Default;
12            objMail.Priority=MailPriority.High;
13            if(this.Attachment.PostedFile.FileName.Trim()!="")
14            {
15                objMail.Attachments.Add(new MailAttachment(this.Attachment.PostedFile.FileName));
16            }

17            SmtpMail.SmtpServer="127.0.0.1";
18            SmtpMail.Send(objMail);
19            Page.RegisterClientScriptBlock("js","<script language=javascript>alert('发送成功!')</script>");
20        }

你可能感兴趣的:(mail)