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

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
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 : 16,947
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,217
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,725
สร้าง Parameter และ Formula Fields บน Crystal Reports (VB.NET,C#)
สร้าง Parameter และ Formula Fields บน Crystal Reports (VB.NET,C#)
บทความ Crystal Report และตัวอย่างการสร้าง Parameters และการส่ง Parameters และการเขียน Formula รับค่าบน Crystal Report
Rating :
Update :
2017-03-24 21:29:30 View : 82,675
C# .NET Generate Excel (Windows 7 and Office Excel 2003 , Excel 2007 , Excel  2010)
C# .NET Generate Excel (Windows 7 and Office Excel 2003 , Excel 2007 , Excel 2010)
ตัวอย่างการใช้ C# ในการสร้างเอกสาร Excel (.xls) โดยใช้ Class Library ของ Microsoft.Office.Interop.Excel
Rating :
Update :
2017-03-24 21:21:31 View : 30,974
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 : 8,887
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 05
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