In this topic, I will introduce how to send email in VB using SMTP/EWS/WebDAV. I will also introduce some advanced features including SSL, S/MIME, Embedded Images, Email Queue and Multiple Threads.
Click here to read original tutorial ...
Tutorial Index
•Send Email using SMTP protocol in A Simple C# Project
•Send Email over SSL connection
•Send Email using Gmail
•Send Email using Yahoo
•Send Email using Hotmail/Live/Office 365 in C#
•Send Email directly without SMTP server(MX DNS lookup) in C#
•Send HTML Email in C#
•Send Email with Attachment in C#
•Send Email with Embedded Images in C#
•Send Email with Digital Signature in C# - S/MIME
•Encrypt Email in C# - S/MIME
•Send Email with Event Handler in C#
•Send Email Asynchronously in C#
•Send Email with Multiple Threads(Mass Mail) in C#
•Send Email with Queue in ASP.NET, C#
•Send Mass Emails using Database Queue in ASP.NET, C#
•Send Email using Exchange Web Service - EWS in C#
•Send Email using Exchange WebDAV in C#
InstallationBefore you can use the following sample codes, you should download the
EASendMail Installer and install it on your machine at first.
A simple VB.NET projectTo better demonstrate how to send email using SMTP protocol, let's create a VB console project at first, and then add the reference of EASendMail in your project.
Add Reference of EASendMail to Visual Stuido VB.NET ProjectTo 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 it to send email in your 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.
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.
EASendMaill45.dll Built with .NET Framework 4.5
It requires .NET Framework 4.5 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.
Now add the following codes to the project and change From, To, Server, User and Password to corresponding value.
[VB - Send Email Example]
Imports EASendMail ' Add EASendMail namespace
Module Module1
Sub Main()
Dim oMail As New SmtpMail("TryIt")
Dim oSmtp As New SmtpClient()
' Set sender email address, please change it to yours
oMail.From = "test@emailarchitect.net"
' Set recipient email address, please change it to yours
oMail.To = "support@emailarchitect.net"
' Set email subject
oMail.Subject = "test email from VB.NET project"
' Set email body
oMail.TextBody = "this is a test email sent from VB.NET project, do not reply"
' Your SMTP server address
Dim oServer As New SmtpServer("smtp.emailarchitect.net")
' User and password for ESMTP authentication, if your server doesn't require
' User authentication, please remove the following codes.
oServer.User = "test@emailarchitect.net"
oServer.Password = "testpassword"
' If your smtp server requires SSL connection, please add this line
' oServer.ConnectType = SmtpConnectType.ConnectSSLAuto
Try
Console.WriteLine("start to send email ...")
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
If you set everything right, you can get "
email was sent successfully". If you get "
failed to send email with the following error:", then please have a look at the following section.
Edited by user Sunday, July 28, 2013 5:17:19 AM(UTC)
| Reason: Not specified