
ConnectType = 4 ' If your server is Exchange 2007 or later version, you can use EWS protocol. ServerPort = 25 ' Using TryTLS, ' If smtp server supports TLS, then TLS connection is used otherwise, normal TCP connection is used.
#Excel 2016 vba and macros tutorial password
Password = "yourpassword" ' Set server port, if 25 port doesn't work, try to use 587 port oSmtp. LicenseCode = "TryIt" ' Please change server address, user, password to yours oSmtp. StatusBar = "Total " & emailSent & " email(s) sent." End Sub Function SendMailTo ( sender, name, address, subject, body, bodyFormat ) Set oSmtp = New EASendMailObjLib. Count Dim sender, name, address, subject, bodyTemplate, body, bodyFormat bodyFormat = 0 'Text body format ' Please change sender address to yours sender = subject = "Test email from Excel and VBA" ' Use a body template to build body text based on recipient's name bodyTemplate = "Dear ", name ) If Not SendMailTo ( sender, name, address, subject, body, bodyFormat ) Then Exit Sub End If emailSent = emailSent + 1 Next Application. " End Sub Public Sub SendMailFromWorkBook () Dim oSheet Set oSheet = ThisWorkbook.

StatusBar = "Sending " & lSent & "/" & lTotal & ". StatusBar = "Connected" End Sub Private Sub oSmtp_OnError ( ByVal lError As Long, ByVal ErrDescription As String ) HasErrorWithEmail = True CurrentEmailIsFinished = True ErrorDescription = ErrDescription End Sub Private Sub oSmtp_OnSending ( ByVal lSent As Long, ByVal lTotal As Long ) Application. StatusBar = "Authenticated" End Sub Private Sub oSmtp_OnClosed () CurrentEmailIsFinished = True End Sub Private Sub oSmtp_OnConnected () Application. Mail Private CurrentEmailIsFinished As Boolean Private HasErrorWithEmail As Boolean Private ErrorDescription As String Private Sub InitVariables () CurrentEmailIsFinished = True HasErrorWithEmail = False ErrorDescription = "" End Sub Private Sub oSmtp_OnAuthenticated () Application.
#Excel 2016 vba and macros tutorial install
' To use the following codes, please download and install ' on your machine Option Explicit Private WithEvents oSmtp As EASendMailObjLib.


