Share email send in vb.net

tridungjoebob

New member
## Gửi email trong vb.net

** Cách gửi email trong vb.net **

Gửi email trong vb.net là một nhiệm vụ tương đối đơn giản.Các bước sau đây sẽ chỉ cho bạn cách gửi email bằng [system.net.mail] (System.Net.Mail Namespace) không gian tên.

1. ** Tạo một thể hiện mới của lớp ** mailmessage **. **

`` `VBNet
Thông điệp mờ như mailmessage mới ()
`` `

2. ** Đặt ** từ **, ** thành ** và ** Chủ đề ** Thuộc tính của đối tượng ** mailMessage **. **

`` `VBNet
message.from = new mailaddress ("sender@example.com")
message.to = new mailaddress ("reason@example.com")
message.subject = "Email kiểm tra"
`` `

3. ** Thêm phần thân của email vào ** mailmessage ** đối tượng. **

`` `VBNet
message.body = "Đây là một email kiểm tra."
`` `

4. ** Tạo một thể hiện mới của lớp ** smtpclient **. **

`` `VBNet
Dim Client dưới dạng smtpclient mới ()
`` `

5. ** Đặt máy chủ ** **, ** cổng ** và ** Thông tin đăng nhập ** Thuộc tính của đối tượng ** SmtpClient **. **

`` `VBNet
client.host = "smtp.gmail.com"
client.port = 587
client.credentials = new System.net.networkcredential ("username@gmail", "mật khẩu")
`` `

6. ** Kết nối với máy chủ SMTP. **

`` `VBNet
client.connect ()
`` `

7. ** Gửi email. **

`` `VBNet
Client.Send (Tin nhắn)
`` `

8. ** Đóng kết nối với máy chủ SMTP. **

`` `VBNet
client.disconnect ()
`` `

Đó là nó!Bây giờ bạn đã gửi thành công một email bằng vb.net.

** Dưới đây là một số tài nguyên bổ sung mà bạn có thể thấy hữu ích: **

* [System.net.mail tài liệu] (System.Net.Mail Namespace)
* [Cách gửi email trong VB.NET] (Other Row Paging Technique Using T-SQL)
* [Gửi email trong vb.net] (https://www.tutorialspoint.com/vbnet/vbnet_sending_email.htmm)

## hashtags

* #Email
* #vb.net
* #SMTP
* #thư
* #gửi
=======================================
## Email Send in vb.net

**How to Send Email in VB.NET**

Sending email in VB.NET is a relatively simple task. The following steps will show you how to send an email using the [System.Net.Mail](https://docs.microsoft.com/en-us/dotnet/api/system.net.mail) namespace.

1. **Create a new instance of the **MailMessage** class.**

```vbnet
Dim message As New MailMessage()
```

2. **Set the **From**, **To**, and **Subject** properties of the **MailMessage** object.**

```vbnet
message.From = New MailAddress("sender@example.com")
message.To = New MailAddress("recipient@example.com")
message.Subject = "Test Email"
```

3. **Add the body of the email to the **MailMessage** object.**

```vbnet
message.Body = "This is a test email."
```

4. **Create a new instance of the **SmtpClient** class.**

```vbnet
Dim client As New SmtpClient()
```

5. **Set the **Host**, **Port**, and **Credentials** properties of the **SmtpClient** object.**

```vbnet
client.Host = "smtp.gmail.com"
client.Port = 587
client.Credentials = New System.Net.NetworkCredential("username@gmail.com", "password")
```

6. **Connect to the SMTP server.**

```vbnet
client.Connect()
```

7. **Send the email.**

```vbnet
client.Send(message)
```

8. **Close the connection to the SMTP server.**

```vbnet
client.Disconnect()
```

That's it! You have now successfully sent an email using VB.NET.

**Here are some additional resources that you may find helpful:**

* [System.Net.Mail documentation](https://docs.microsoft.com/en-us/dotnet/api/system.net.mail)
* [How to Send Email in VB.NET](https://www.codeproject.com/Articles/10227/How-to-Send-Email-in-VB-NET)
* [Sending Email in VB.NET](https://www.tutorialspoint.com/vbnet/vbnet_sending_email.htm)

## Hashtags

* #Email
* #vb.net
* #SMTP
* #Mail
* #Send
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top