1. 程式人生 > >C#中用126smtp傳送郵件.

C#中用126smtp傳送郵件.

private void Button1_Click(object sender, System.EventArgs e)
  {
  if(IsValid)
  {
   Label13.Text="Welcome "+ TextBox1.Text +" "+TextBox2.Text + ".You have successfully registered.";
   HttpCookie mycookie=new HttpCookie("WebShoppe","You have visited the WebShoppe Site.");
   mycookie.Expires=System.Convert.ToDateTime("12/12/2005");
   Response.Cookies.Add(mycookie);
   MailMessage msg = new MailMessage();
   StringWriter strwriter =new StringWriter();
   HtmlTextWriter htmltxtwriter =new HtmlTextWriter(strwriter);
   htmltxtwriter.RenderBeginTag("html"); 
   htmltxtwriter.RenderBeginTag("head");
   htmltxtwriter.RenderBeginTag("title");
   htmltxtwriter.Write("Thank You!");
   htmltxtwriter.RenderEndTag();
   htmltxtwriter.RenderEndTag();
   htmltxtwriter.RenderBeginTag("body");
   htmltxtwriter.WriteLine("Thank you for registering with WebShoppe Site!");
   htmltxtwriter.RenderEndTag();
   htmltxtwriter.RenderEndTag();
   msg.From ="

[email protected]"; //要用在126smtp中註冊過的郵箱,並和下面程式碼中的註冊名及密碼要相符
   msg.To=TextBox12.Text;
   msg.Bcc="[email protected]";
   msg.Subject="Thanks for registering";
   msg.Body=strwriter.ToString();
   msg.BodyFormat=MailFormat.Html;
   msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate
", "1"); //確認需要認證 
   msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "pangtianbing"); //設定在smtp中使用的使用者名稱 
   msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "**********"); //設定在smtp中使用的密碼. 

   SmtpMail.SmtpServer="smtp.126.com";

   SmtpMail.Send(msg);
  }
  } 

相關推薦

C#中用126smtp傳送郵件.

private void Button1_Click(object sender, System.EventArgs e)  {  if(IsValid)  {   Label13.Text="Welcome "+ TextBox1.Text +" "+TextBox2.Te

c# STMP類傳送郵件

System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient { Host = "smtp.163.com",//使用163的SMTP伺服器傳送郵

C#中自動傳送郵件的實現

原始碼: using System; using System.Windows.Forms; using System.Net.Mail; using System.Text.RegularExpressions; namespace 郵件 { public partial clas

C#使用smtp傳送郵件

1 //簡單郵件傳輸協議類 2 System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(); 3 client.Host = "smtp.163.co

SharePoint 2010 中用程式碼傳送郵件的兩種方式

1. 使用SPUtility.SendEmail, 名稱空間:    Microsoft.SharePoint.Utilities  程式集:   Microsoft.SharePoint (in Microsoft.SharePoint.dll): StringDic

[C#]SmtpClient傳送郵件

這幾天開發的從資料庫抓起資料處理完已郵件發出來,只實現的To的個人的傳送,To的群組,CC的個人和群組,BCC的個人和群組都沒有成功。試了好久,感覺是Exchange伺服器配置的問題,但又無法訪問Exchange的伺服器,所以暫時先放棄完善。 測試的過程中瞭解好多隻是,現在記錄一下 下面的程式碼示例演示如

C#實現.Net對郵件進行DKIM簽名和驗證,支援附件,傳送郵件簽名後直接投遞到對方伺服器(無需己方郵件伺服器)

專案地址 github.com/xiangyuecn/… 主要支援 對郵件進行DKIM簽名,支援帶附件 對整個郵件內容(.eml檔案)的DKIM簽名進行驗證 對MailMessage、SmtpClient進行了一次封裝,傳送郵件簡單易用,進行DKIM簽名後直接投遞到對方伺服器(無需己方郵件

C# 傳送郵件(帶附加件傳送

有時候不太適合寫這些東西:不太會描述,因為在開發過程中遇到了,所以記錄一下,以便後面看看。 由於開發一直用的VS2015或者VS2017,所以不知道其他的版本開發情況,其實差不多 這是下面的核心程式碼:簡單的傳送郵件(不發附件):去掉新增附近的程式碼即可 string user = "***@163.

C# 傳送郵件功能實現

郵件傳送功能在OA以及一些網站驗證中很常用。下面是郵件傳送的一個函式,引數傳入收件人地址,郵件主題,郵件內容,讀者可根據自己的需求新增郵件的附件或者抄送人等。  /// <summary> /// 傳送郵件 /// </su

c# .net傳送郵件方法

一、傳送郵件方法 1 ///<summary> 2 /// 傳送郵件方法 3 ///</summary> 4 ///<param name="mailTo">收件人郵箱</param

關於C#如何利用QQ郵箱SMTP傳送郵件

 今天寫傳送郵件的時候,用163可以正常傳送,但是利用QQ傳送不了郵件,後來發現是QQ郵箱的SMTP使用了SSL加密,所有必須啟用SSL加密,並且指定埠就可以傳送了。 public vo

c語言利用SMTP協議傳送郵件

#ifdef WIN32 #include <windows.h> #include <stdio.h> #else #include <stdio.h> #include <sys/types.h> #include

C# 傳送郵件內容嵌入圖片

我們在傳送郵件時,一般圖片都是用網路路徑,但有時如果接收方不可直接訪問外網,就不能看到圖片了,比如公司內部郵件,跟外界就沒法交流圖片。 那麼我們就來把圖片嵌入郵件中;檢視人就沒有限制了。 1。以linked的方式,此方式在郵件中不會出現圖片的附件   郵件內容呼

c# 自動傳送郵件測試程式碼

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq;

C#傳送郵件(新增附件)!

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.T

c#幫助類:傳送郵件

1 private static string IsOpenSendMail = ConfigurationManager.AppSettings["IsOpenSendMail"]; //是否啟用異常訊息傳送郵箱功能 2 private static string

C#傳送郵件

public class Email { /// <summary> /// 傳送者 /// </summary> public string mailFrom { get; s

C++ 使用smtp協議傳送郵件的簡單實現

心血來潮,簡單實現一個傳送郵件的小程式, 首先實現一個簡單的socket類 標頭檔案 #ifndef _CSOCKET_H_ #define _CSOCKET_H_ #include <sys/socket.h> #include <arpa/inet

使用.net(C#)傳送郵件(帶成功案例)

1.瞭解傳送郵件的三種方式  第一:client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;  //通過遠端SMTP伺服器傳送該郵件,這裡的network表示你要使用的遠端SMTP伺服器。  第

C#呼叫Mail傳送QQ郵件

需要用到: 1.System.Net.Mail; 2.QQ郵箱的POP3/SMTP服務碼 QQ郵箱的POP3/SMTP服務碼獲取方法: 1.開啟qq郵箱: 2.進入設定頁面--》賬戶:(往下翻)開啟服務POP3/SMTP服務,QQ郵箱會給一個POP3/SMTP服務碼儲存下