Sub SendEmailUsingCDO(ByVal strTo As String, ByVal strCC As String, _
ByVal strBCC As String, ByVal strHTMLBody As String, _
ByVal strFrom As String, ByVal strSubject As String, _
ParamArray Attachments() As Variant)
Dim email As New CDO.Message
Dim i As Integer
With email
For i = 0 To UBound(Attachments)
If dir(Attachments(i)) <> "" Then
.AddAttachment Attachments(i)
End If
Next i
.HTMLBody = strHTMLBody
.From = strFrom
.To = strTo
.Subject = strSubject
.Configuration.fields.item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
[green]'Name or IP of Remote SMTP Server[/green]
.Configuration.fields.item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = "smtp.ev1.net"
[green]'Type of authentication, NONE, Basic (Base64 encoded), NTLM[/green]
.Configuration.fields.item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/authenticate")[/URL] = cdoBasic
[green]'Your UserID on the SMTP server[/green]
.Configuration.fields.item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusername")[/URL] = "MyUsername"
[green]'Your password on the SMTP server[/green]
.Configuration.fields.item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendpassword")[/URL] = "MyPassword"
[green]'Server port (typically 25)[/green]
.Configuration.fields.item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25
[green]'Use SSL for the connection (False or True)[/green]
.Configuration.fields.item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpusessl")[/URL] = False
[green]'Connection Timeout in seconds (the maximum time
'CDO will try to establish a connection to the SMTP server)[/green]
.Configuration.fields.item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")[/URL] = 60
.Configuration.fields.Update
[green]'==End remote SMTP server configuration section==[/green]
.Send
End With
End Sub