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
ตัวอย่าง 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 : 18,182
การสร้าง Crystal Report กับการสร้าง Class และ DataSource (.NET)
การสร้าง Crystal Report กับการสร้าง Class และ DataSource (.NET)
ตัวอย่างการสร้าง class บน .net framework เพื่อสร้าง dataset และ datatable กำหนดค่า datasource ให้กับ crystal report
Rating :
Update :
2017-03-24 21:32:24 View : 22,679
Basic jQuery for AJAX in ASP.NET Web Site พื้นฐาน Ajax กับ ASP.NET ด้วย jQuery
Basic jQuery for AJAX in ASP.NET Web Site พื้นฐาน Ajax กับ ASP.NET ด้วย jQuery
บทความ jQuery กับการใช้งาน Ajax บน ASP.NET Framework ทำความเข้าใจพื้นฐานการทำงานกับ Ajax ด้วย jQuery กับ ASP.NET แบบง่าย ๆ เบสิก
Rating :
Update :
2017-03-24 21:23:54 View : 22,374
Generating Excel Report in .NET Framework
Generating Excel Report in .NET Framework
สร้างไฟล์เอกสาร Excel บน Windows Application และ Console Application ด้วย Framework
Rating :
Update :
2017-03-24 21:16:47 View : 10,094
ADO.NET and Oracle  (VB.NET/C#) เขียนโปรแกรมติดต่อกับฐานข้อมูล Oracle Database
ADO.NET and Oracle (VB.NET/C#) เขียนโปรแกรมติดต่อกับฐานข้อมูล Oracle Database
ADO.NETกับฐานข้อมูล Oracle การสร้าง Connection String และการเชื่อมต่อผ่าน TNS Name
Rating :
Update :
2017-03-24 21:28:07 View : 22,502
ASP.NET GridView and Checkbox Select All Row Using jQuery
ASP.NET GridView and Checkbox Select All Row Using jQuery
บทความ ASP.NET การใช้งาน jQuery เพื่อเลือกแถว Checkbox ใน GridView เลือกแถวทั้งหมด หรือไม่เลือกทั้งหมด
Rating :
Update :
2017-03-17 22:11:54 View : 17,506
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 อัตราราคา คลิกที่นี่