' -------------------------------------------------------------------------------- ' To send mail using CDO.Sys must set a reference to Microsoft CDO 1.21
can be downloaded from MSDN Downloads (if not already installed) ' -------------------------------------------------------------------------------- Set imsg = CreateObject("cdo.message")
Set iconf = CreateObject("cdo.configuration")
Set Flds = iconf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = txtSMTPServer.Text
' if authentication is called for If chkAuthentication.Value = 1 Then
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = txtUser.Text
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = txtPassword.Text
End If
' --------------------------------- .Update
End With
With imsg
Set .Configuration = iconf
.To = strReceiverEmail
.From = strFrom
' if you wish to receive a copy If chkEmailCC.Value = 1 Then
.cc = txtYourEmail.Text
End If
' ------------------------------- .Subject = strSubject
.HtmlBody = strHTML
.Fields.Update
.Send
End With
Set imsg = Nothing
Set iconf = Nothing