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,038

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



.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
     


Related Links
ASP.NET กับแนวคิดการออกแบบ WebPage การวาง Layout ของหน้าเว็บและการเปลี่ยน URL
ASP.NET กับแนวคิดการออกแบบ WebPage การวาง Layout ของหน้าเว็บและการเปลี่ยน URL
บทความนี้เป็นเทคนิคและแนวคิดการวาง Layout โครงสร้างหน้า Webpage บน Web Form ของ ASP.NET ผ่าน Web User Control
Rating :
Update :
2017-03-24 21:15:24 View : 36,270
Install .NET Framework 2.0 & Visual Studio 2005
Install .NET Framework 2.0 & Visual Studio 2005
Install .NET Framework 2.0 & Visual Studio 2005 ติดตั้งและใช้งาน .NET Framework 2.0 และ VS 2005
Rating :
Update :
2009-01-11 09:44:53 View : 9,310
VB.NET/C# Connect to SQL Server Using ADO.NET พื้นฐานกับ SQL Server and ADO.NET
VB.NET/C# Connect to SQL Server Using ADO.NET พื้นฐานกับ SQL Server and ADO.NET
SQL Server เชื่อมติดต่อผ่าน ADO.NET เพื่อเขียนโปรแกรมด้วยภาษา VB.NET และ C#
Rating :
Update :
2017-03-24 21:30:04 View : 63,036
ติดตั้ง Crystal Report ให้กับ Visual Studio 2012 (.NET 4.5) และเพิ่ม Items Control ลงใน Reporting
ติดตั้ง Crystal Report ให้กับ Visual Studio 2012 (.NET 4.5) และเพิ่ม Items Control ลงใน Reporting
ติดตั้ง crystal report ให้กับ visual studio 2012 ซึ่งปกติตอนที่ทำการ setup โปรแกรม vs 2012 จะไม่มีเป็น package มาให้ แต่จะต้องดาวน์โหลดเพื่อติดตั้งเพิ่มเติม
Rating :
Update :
2017-03-17 21:25:45 View : 52,177
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 : 67,978
ASP.NET กับ JSON และการรับ-ส่งข้อมูล JSON ผ่าน Web Service (VB.NET , C#)
ASP.NET กับ JSON และการรับ-ส่งข้อมูล JSON ผ่าน Web Service (VB.NET , C#)
การนำ json มาใช้งานร่วมกับ asp.net ในการรับส่งข้อมูล json ผ่าน web service การเข้ารหัสและถอดรหัส json บนภาษา vb.net และ c#
Rating :
Update :
2017-03-24 21:33:02 View : 61,554
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
   





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