vb6发送电子邮件_如何使用VB.Net发送电子邮件

vb6发送电子邮件

Sending and receiving emails has now became an important task in our daily life. Email service providers such as Hotmail, Gmail & Yahoo have provided their SMTP Ports so that third party developers can use them in their applications.

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.

Sending and receiving emails has now became an important task in our daily life. Email service providers such as Hotmail, Gmail & Yahoo have provided their SMTP Ports so that third party developers can use them in their applications.

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发送电子邮件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值