Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 6

http://www.emailarchitect.net/easendmail/ex/vb/5.

aspx

vb.net sending email

Visual Basic.NET - Send Email using Yahoo Account

Yahoo SMTP server address is "smtp.mail.yahoo.com". It supports both Normal and SSL
connection to do user authentication, and you should use your Yahoo email address as the user
name for ESMTP authentication. For example: your email is "myid@yahoo.com", and then the
user name should be "myid@yahoo.com".

If you want to use SSL connection with Yahoo SMTP server, you must set the port to 465. The
following example codes demonstrate how to send email using Yahoo SMTP server.

Installation

Before you can use the following sample codes, you should download the EASendMail
Installer and install it on your machine at first.

Add Reference of EASendMail to Visual Basic.NET Project

To use EASendMail SMTP Component in your project, the first step is "Add reference of
EASendMail to your project". Please create/open your project with Visual Studio.NET, then
choose menu->"Project"->"Add Reference"->".NET"->"Browse...", and choose the
EASendMail{version}.dll from your disk, click "Open"->"OK", the reference of EASendMail will
be added to your project, and you can start to use EASendMail to send email in your Visual
Basic.NET project.

Because EASendMail has separate builds for .Net Framework, please refer to the following table
and choose the correct dll.
Separate builds of run-time assembly for .Net Framework 1.1, 2.0, 3.5, 4.0 and .Net
Compact Framework 2.0, 3.5.

File .NET Framework Version

EASendMail.dll Built with .NET Framework 1.1 


It requires .NET Framework 1.1, 2.0, 3.5 or later
version.

EASendMail20.dll Built with .NET Framework 2.0 


It requires .NET Framework 2.0, 3.5 or later
version.

EASendMail35.dll Built with .NET Framework 3.5 


It requires .NET Framework 3.5 or later version.

EASendMaill40.dll Built with .NET Framework 4.0 


It requires .NET Framework 4.0 or later version.

EASendMailCF20.dll Built with .NET Compact Framework 2.0 


It requires .NET Compact Framework 2.0, 3.5 or
later version.

EASendMailCF35.dll Built with .NET Compact Framework 3.5 


It requires .NET Compact Framework 3.5 or later
version.

C# | VB6 | Visual Basic.NET | Managed C++ | Visual C++ | Delphi

' The following example codes demonstrate sending email message using Yahoo
SMTP server.
' To get full sample projects, please download and install EASendMail on
your machine.
' To run it correctly, please change SMTP server, user, password, sender,
recipient value to yours

' Add EASendMail Namespace


Imports EASendMail 

Module Module1 
    Sub Main() 
        Dim oMail As New SmtpMail("TryIt") 
        Dim oSmtp As New SmtpClient() 

        ' Your Yahoo email address


        oMail.From = "myid@yahoo.com" 

        ' Set recipient email address, please change it to yours


        oMail.To = "support@emailarchitect.net" 

        ' Set email subject


        oMail.Subject = "test email from yahoo account" 
        ' Set email body
        oMail.TextBody = "this is a test email sent from VB.NET project with
yahoo" 

        ' Yahoo SMTP server address


        Dim oServer As New SmtpServer("smtp.mail.yahoo.com") 

        ' For example: your email is "myid@yahoo.com", then the user should
be "myid@yahoo.com"
        oServer.User = "myid@yahoo.com" 
        oServer.Password = "yourpassword" 

        ' Because yahoo deploys SMTP server on 465 port with direct SSL
connection.
        ' So we should change the port to 465.
        oServer.Port = 465 

        ' detect SSL/TLS type automatically


        oServer.ConnectType = SmtpConnectType.ConnectSSLAuto 

        Try 

            Console.WriteLine("start to send email over SSL ...") 


            oSmtp.SendMail(oServer, oMail) 
            Console.WriteLine("email was sent successfully!") 

        Catch ep As Exception 

            Console.WriteLine("failed to send email with the following


error:") 
            Console.WriteLine(ep.Message) 
        End Try 

    End Sub 
End Module 

http://www.emailarchitect.net/easendmail/kb/vbnet.aspx?cat=3
end Email using Yahoo in VB.NET
Date: Oct 14, 2013

In previous section,I introduced how to send email using Gmail account. In this section, I will
introduce how to send email using Yahoo account in VB.NET.

Yahoo SMTP server address is "smtp.mail.yahoo.com". It supports both Normal/Implicit


SSL/Explicit SSL (TLS) connection to do user authentication, and you should use your Yahoo
email address as the user name for ESMTP authentication. For example: your email is
"myid@yahoo.com", and then the user name should be "myid@yahoo.com".

If you want to use implicit SSL connection with Yahoo SMTP server, you must set the port to
465.

Remarks: All of samples in this section are based on first section: Send email in a simple
VB.NET project. To compile and run the following example codes successfully, please
click here to learn how to create the test project and add reference of EASendMail to your
project.

[VB.NET - Send Email using Yahoo over Implicit SSL on 465 Port - Example]

The following example codes demonstrate how to send email using Yahoo account in VB over
SSL 465 port. To get full sample projects, please refer to Samples section.

Imports EASendMail 'Add EASendMail namespace

Module Module1
Sub Main()
Dim oMail As New SmtpMail("TryIt")
Dim oSmtp As New SmtpClient()

' Your Yahoo email address


oMail.From = "myid@yahoo.com"

' Set recipient email address, please change it to yours


oMail.To = "support@emailarchitect.net"

' Set email subject


oMail.Subject = "test email from yahoo account"

' Set email body


oMail.TextBody = "this is a test email sent from VB.NET project with
yahoo"
' Yahoo SMTP server address
Dim oServer As New SmtpServer("smtp.mail.yahoo.com")

' For example: your email is "myid@yahoo.com", then the user should
be "myid@yahoo.com"
oServer.User = "myid@yahoo.com"
oServer.Password = "yourpassword"

' Because yahoo deploys SMTP server on 465 port with implicit SSL
connection.
' So we should change the port to 465.
oServer.Port = 465

' detect SSL/TLS type automatically


oServer.ConnectType = SmtpConnectType.ConnectSSLAuto

Try

Console.WriteLine("start to send email over SSL ...")


oSmtp.SendMail(oServer, oMail)
Console.WriteLine("email was sent successfully!")

Catch ep As Exception

Console.WriteLine("failed to send email with the following


error:")
Console.WriteLine(ep.Message)
End Try

End Sub
End Module

[VB.NET - Send Email using Yahoo over Explicit SSL (TLS) on 25 or 587 Port - Example]

The following example codes demonstrate how to send email using Yahoo account in VB.NET
over TLS 25 port. To get full sample projects, please refer to Samples section.

Imports EASendMail 'Add EASendMail namespace

Module Module1
Sub Main()
Dim oMail As New SmtpMail("TryIt")
Dim oSmtp As New SmtpClient()

' Your Yahoo email address


oMail.From = "myid@yahoo.com"
' Set recipient email address, please change it to yours
oMail.To = "support@emailarchitect.net"

' Set email subject


oMail.Subject = "test email from yahoo account"

' Set email body


oMail.TextBody = "this is a test email sent from VB.NET project with
yahoo"

' Yahoo SMTP server address


Dim oServer As New SmtpServer("smtp.mail.yahoo.com")

' For example: your email is "myid@yahoo.com", then the user should
be "myid@yahoo.com"
oServer.User = "myid@yahoo.com"
oServer.Password = "yourpassword"

' set 25 port, if you want to use 587 port, please change 25 to 587
oServer.Port = 25

' detect SSL/TLS type automatically


oServer.ConnectType = SmtpConnectType.ConnectSSLAuto

Try

Console.WriteLine("start to send email over SSL ...")


oSmtp.SendMail(oServer, oMail)
Console.WriteLine("email was sent successfully!")

Catch ep As Exception

Console.WriteLine("failed to send email with the following


error:")
Console.WriteLine(ep.Message)
End Try

End Sub
End Module

You might also like