Public Function SimpleSendEMailWithCDO() As Boolean
Dim iCfg As Object
Dim iMsg As Object
On Error GoTo SimpleSendEMailWithCDO_Error
Set iCfg = CreateObject("CDO.Configuration")
Set iMsg = CreateObject("CDO.Message")
With iCfg.Fields
' Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
' Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
.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") = "mail.so.centurytel.net"
' cdoBasic 1
' Use basic (clear-text) authentication.
' The configuration sendusername/sendpassword or postusername/postpassword fields are used to specify credentials.
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "ctr69265"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "c9j56a5c"
.Item("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = "MaltShoppe <System@MaltShoppe.Net>"
' 'Use SSL for the connection (False or True)
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
' 'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Update
End With
With iMsg
.configuration = iCfg
.Subject = "Your Subject"
.To = "YourDestination@SomeISP.net"
' .Cc = ""
' .Bcc = ""
.TextBody = "See attachment"
.AddAttachment CurrentProject.Path & AttachFile
.Send
End With
Set iMsg = Nothing
Set iCfg = Nothing
SimpleSendEMailWithCDO = True
SimpleSendEMailWithCDO_Exit:
On Error GoTo 0
Exit Function
SimpleSendEMailWithCDO_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure SimpleSendEMailWithCDO of Module basCDO"
SimpleSendEMailWithCDO = False
Resume SimpleSendEMailWithCDO_Exit
End Function