![](https://i-blog.csdnimg.cn/blog_migrate/0dff9537952c0b4ffade2838e0026a13.png)
vb6发送电子邮件
In visual basic.net we use SMTP i.e Simple Mail Transfer Protocal which help us in composing electronic mails and send them to various sources.
Also Read: SQL Injection Attacks – How to Prevent VB.Net Database Applications
We need to import the following namespace “Imports System.Net.Mail” in order to use the SMTP class.
About System.Net.Mail Namespace
This Namespace provides various list of classes that help us to create, send, receive and do many other email related tasks.
You can get a more detailed information from the Microsoft Developer Network’s website http://msdn.microsoft.com/en-us/library/system.net.mail(v=vs.110).aspx
How to Send Email Using VB.Net
I’ll demonstrate a simple example that allow us to send emails in vb.net:
1. Create a new windows form application project in visual basic.net.
2. Add three labels and three textboxes and name them as given below:
Label1 – To
Label2 – Subject
Label3 – Body
3. Add a button and change its text to Send.
4. Double click button to switch to code view and paste the code given below.
5. Change youremail with your current email address and yourpassword with your email ID’s password. Don’t forget to import the following namespace: Imports System.Net.Mail
That’s it!! Run your Project and send a test email.
Note: It works only with Gmail Account because we have used Gmail’s SMTP Port.
In visual basic.net we use SMTP i.e Simple Mail Transfer Protocal which help us in composing electronic mails and send them to various sources.
Also Read: SQL Injection Attacks – How to Prevent VB.Net Database Applications
We need to import the following namespace “Imports System.Net.Mail” in order to use the SMTP class.
About System.Net.Mail Namespace
This Namespace provides various list of classes that help us to create, send, receive and do many other email related tasks.
You can get a more detailed information from the Microsoft Developer Network’s website http://msdn.microsoft.com/en-us/library/system.net.mail(v=vs.110).aspx
How to Send Email Using VB.Net
I’ll demonstrate a simple example that allow us to send emails in vb.net:
1. Create a new windows form application project in visual basic.net .
2. Add three labels and three textboxes and name them as given below:
Label1 – To
Label2 – Subject
Label3 – Body
3. Add a button and change its text to Send.
4. Double click button to switch to code view and paste the code given below.
5. Change youremail with your current email address and yourpassword with your email ID’s password. Don’t forget to import the following namespace: Imports System.Net.Mail
That’s it!! Run your Project and send a test email.
Note: It works only with Gmail Account because we have used Gmail’s SMTP Port.
翻译自: https://www.thecrazyprogrammer.com/2014/11/how-to-send-email-using-vb.html
vb6发送电子邮件