Public Sub VerySimpleSendMailWithCDOSample()
Dim iCfg As Object
Dim iMsg As Object
Set iCfg = CreateObject("CDO.Configuration")
Set iMsg = CreateObject("CDO.Message")
With iCfg.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")= 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="smtp.server.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")= 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") ="MyUserName"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="MyPassordNotAlwaysNeeded"
.Item("http://schemas.microsoft.com/cdo/configuration/sendemailaddress")= "email@address.com.au"
.Update
End With
.Update
End With
With iMsg
.Configuration = iCfg
.Subject = "Subject"
.To = "recipient.email@address.com.au"
.TextBody = "MessageBody"
.AddAttachment "FullPathToAttachment"
.Send
End With
Set iMsg = Nothing
Set iCfg = Nothing
End Sub