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

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
DataGridView , ComboBox , ListBox : Basic in (.NET) Windows Forms Application
DataGridView , ComboBox , ListBox : Basic in (.NET) Windows Forms Application
Basic พื้นฐานการสร้าง DataGridView , ComboBox , ListBox บน Windows Form ด้วย Wizard ของ Visual Studio
Rating :
Update :
2017-03-24 21:18:46 View : 30,848
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,605
.NET Smart Device  เขียนโปรแกรมบน Smartphone, Pocket PC , Windows CE , Window  Mobile 5-6, Hand Held,...
.NET Smart Device เขียนโปรแกรมบน Smartphone, Pocket PC , Windows CE , Window Mobile 5-6, Hand Held,...
.NET Smart Device Project เขียนโปรแกรมบน Smartphone, Pocket PC , Windows CE , Window Mobile 5-6, Hand Held,...
Rating :
Update :
2017-03-24 21:17:48 View : 41,630
การสร้างฟอร์มด้วย DataGridView เบื้องต้นแบบ Step by Step [ VB.NET (Windows App+SQL Server) ]
การสร้างฟอร์มด้วย DataGridView เบื้องต้นแบบ Step by Step [ VB.NET (Windows App+SQL Server) ]
การสร้างฟอร์มด้วย DataGridView เบื้องต้นแบบ Step by Step Development Tool: Visual Studio 2010 Express Database Engine: MS SQL Server 2005 Express
Rating :
Update :
2011-07-24 19:33:14 View : 19,795
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 : 35,691
.NET Framework รวบรวมเทคนิคการพัฒนาโปรแกรมด้วย .NET ทั้ง VB.NET และ C#
.NET Framework รวบรวมเทคนิคการพัฒนาโปรแกรมด้วย .NET ทั้ง VB.NET และ C#
หัวข้อนี้ผมได้รวบรมเทคนิคต่าง ๆ ที่เกี่ยวข้องกับการพัฒนาโปรแกรมด้วย .NET Framework ครบคลุมทั้ง Framework 1,2,3 และภาษา VB.NET,C#
Rating :
Update :
2017-03-24 21:23:16 View : 15,413
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 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่

Inline