Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,019

HOME > .NET Framework > .NET Windows Form กับการส่งอีเมล์ (Send Mail) แบบง่าย ๆ ด้วย System.Net.Mail (VB.NET , C#)




Clound SSD Virtual Server

.NET Windows Form กับการส่งอีเมล์ (Send Mail) แบบง่าย ๆ ด้วย System.Net.Mail (VB.NET , C#)

 
  .NET Windows Form Send Mail Using System.Net.Mail การเขียนส่งอีเมล์ กับ .NET Framework การเขียน Windows Form ส่งอีเมล์ แบบง่าย ๆ ด้วย Namespace ของ System.Net.Mail

ใน .NET Framework การส่งอีเมล์แล้วหลัก ๆ มี Namespace รองรับ 2 ตัวคือ System.Web.Mail ซึ่งใช้งานบน ASP.NET แต่ทั้งนี้ก็สามารถใช้งานบน Windows Form ได้เช่นเดียวกัน เพียงแต่ทำการ Add Reference ของ System.Web.Mail เข้ามาเท่านั้น ซึ่งสามารถอ่านได้จากความความของ ASP.NET กับการส่งอีเมล์

Go to : ASP.NET Send Email

หรือจะใช้ System.Net.Mail ซึ่งเป็นค่า Default ที่ถูกใช้งานใน Windows Form ตามตัวอย่างต่อไปนี้


Windows Form Send Mail System.Net.Mail

ขั้นแรกให้ทำการ Add Reference ก่อนครับ


Windows Form Send Mail System.Net.Mail

เลือก Namespace ชื่อ System.Net








Code เต็ม ๆ

Windows Form Send Mail System.Net.Mail

ให้ออกแบบ Form ดังรูป

Code for VB.NET
    Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click

        Dim myMail As New MailMessage()

        myMail.From = New MailAddress("[email protected]")
        myMail.To.Add(New MailAddress(Me.txtTo.Text))

        myMail.Subject = Me.txtSubject.Text
        myMail.Body = Me.txtMessage.Text

        myMail.Priority = MailPriority.High ' MailPriority.High , MailPriority.Low  MailPriority.Normal


        Dim Client As New SmtpClient()
        'Client.Host = "192.168.0.1"
        Client.Send(myMail)

        MessageBox.Show("Mail Send Complete!")

    End Sub


Code for C#
private void btnSend_Click(System.Object sender, System.EventArgs e)
{
	MailMessage myMail = new MailMessage();

	myMail.From = new MailAddress("[email protected]");
	myMail.To.Add(new MailAddress(this.txtTo.Text));

	myMail.Subject = this.txtSubject.Text;
	myMail.Body = this.txtMessage.Text;

	myMail.Priority = MailPriority.High;
	// MailPriority.High , MailPriority.Low  MailPriority.Normal


	SmtpClient Client = new SmtpClient();
	//Client.Host = "192.168.0.1";
	Client.Send(myMail);

	MessageBox.Show("Mail Send Complete!");

}



Screenshot

Windows Form Send Mail System.Net.Mail


       
Bookmark.   
       

 

  By : TC Admin
  Score Rating : -
  Create Date : 2011-09-07 11:05:49
  Download : No files
     

Clound SSD Virtual Server
-->
Related Links
การสร้าง Crystal Report กับ DataSet หรือ DataTable (VB.NET,C#)
การสร้าง Crystal Report กับ DataSet หรือ DataTable (VB.NET,C#)
บทความนี้ Advanced ขึ้นมาอีกนิดสำหรับการสร้าง Report ของ Crystal Report กับ DataSet หรือ DataTable ของ .NET Framework
Rating :
Update :
2017-03-24 21:28:46 View : 125,066
Shared Folder or Map Drive in Emulator Smart Device Mobile Application
Shared Folder or Map Drive in Emulator Smart Device Mobile Application
การสร้าง Shared Folder ระหว่าง Emulator กับ PC Desktop ในการย้ายข้อมูลระหว่าง Emulator กับ Notebook หรือ PC Desktop
Rating :
Update :
2017-03-24 21:17:19 View : 8,424
Crystal Report กับการสร้าง Report รายงานแบบ JOIN ข้อมูลหลายตาราง Table (.NET)
Crystal Report กับการสร้าง Report รายงานแบบ JOIN ข้อมูลหลายตาราง Table (.NET)
ตัวอย่างการออก report ของ crystal report ที่มีความซับซ้อนยิ่งขึ้น และการนำข้อมูลหลาย ๆ ตารางมาแสดง ใน report เดียวกัน
Rating :
Update :
2017-03-17 21:20:01 View : 64,541
C# .NET Create Word Document (Windows 7 and Office 2003 , Office Word 2007)
C# .NET Create Word Document (Windows 7 and Office 2003 , Office Word 2007)
ตัวอย่างการใช้ C# ในการสร้างเอกสาร Word (.doc) โดยใช้ Class Library ของ Microsoft.Office.Interop.Word
Rating :
Update :
2017-03-17 22:12:40 View : 11,096
Generating Word Document in .NET Framework
Generating Word Document in .NET Framework
สร้างไฟล์เอกสาร Word Document บน Windows Application และ Console Application ด้วย Framework
Rating :
Update :
2017-03-24 21:20:55 View : 6,450
ตัวอย่าง Web(ASP.NET ) Shopping Cart Source Code
ตัวอย่าง Web(ASP.NET ) Shopping Cart Source Code
ตัวอย่างระบบ Shopping Cart แบบง่าย ๆ พัฒนาด้วยภาษา VB.NET และ C# มีตัวอย่างให้ดาวน์โหลด
Rating :
Update :
2012-03-17 06:41:21 View : 17,528
ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2023 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่

Inline