Code to send an email.
Sub Send_Email(emailMessage)
Dim message As Object
Dim config As Object
Dim Flds As Variant
Set message = CreateObject("CDO.Message")
Set config = CreateObject("CDO.Configuration")
config.Load -1 ' CDO Source Defaults
Set Flds = config.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "" 'smptp server info
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With
With message
Set .Configuration = config
.to = ""
.CC = ""
.BCC = ""
.From = ""
.Subject = ""
.TextBody = emailMessage
.Send
End With
End Sub
Additional functions
Request read receipt
' To be added within With message
' Request read receipt
.Fields("urn:schemas:mailheader:return-receipt-to") = "email"
' Request delivery receipt
.Fields("urn:schemas:mailheader:disposition-notification-to") = "email"
Attachment
' To be added within With message
' File needs to be closed
.AddAttachment “FilePath”
Source
https://www.rondebruin.nl/win/s1/cdo.htm