2016-01-21 38 views
-6

我有搜索許多網站。但我無法忽略他們所說的話。他們告訴他們在互聯網上創建CDO文件。ASP.NET如何爲郵件發件人編寫代碼?

請幫我在我的項目中發送郵件。我有3個文本框:

  1. Tomail
  2. 標題
  3. 內容的消息
  4. 發送按鈕
+0

嘗試http://www.aspsnippets.com/Articles/Send-email-using-Gmail-SMTP-Mail-Server-in-ASPNet.aspx..explain在brief..First試試這個..如果您在嘗試使用 – Dhara

+0

的郵政編碼之間遇到任何問題,我不知道您如何搜索https://www.google.co.uk/search?sourceid=chrome-psyapi2&ion=1&espv=2&ie=UTF-8&q= %20to%20send%20mail%20in%20asp.net&oq = how%20to%20send%20mail%20in%20asp.net&rlz = 1C1PRFC_enGB670GB670&aqs = chrome..69i57j0l5.10924j0j7 – Imad

+0

Your page not Found – Parameswaran

回答

0

使用下面的代碼來發送郵件。

  MailMessage mail = new MailMessage(); 
      SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); 

      mail.From = new MailAddress("[email protected]"); 
      mail.To.Add("[email protected],[email protected]"); 
      mail.Subject = "Report"; 
      mail.Body = "This is a Stack overflow using report"; 
      Attachment attachment = new Attachment(filename); 
      mail.Attachments.Add(attachment); 

      SmtpServer.Port = 25; 
      SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password"); 
      SmtpServer.EnableSsl = true; 

      SmtpServer.Send(mail); 
相關問題