I'm using the following code to send emails from my database:
I would like to be able to verify that the email was sent. I know that delivery confirmation requests can be used, but that is dependent on the receiver allowing it to be sent so it isn't totally dependable.
The other idea that I had was change it from a sub to a function and use it as a flag of some sort. I would just have to trust that since the email addresses are saved in the database that they are accurate. If there was an error going through the code, then the error handler would set the function to 1. If the function didn't have an error, then the function would return a 0. Is this a valid idea or does it make me worthy of brain surgery to fix the cobwebs in my brain?
Code:
Public Sub SendEmail(strSubject As String, strText As String, _
strTo As String, Optional strFrom As String)
Dim cdoConfig As Object
Dim msgOne As Object
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "Exchange.ftc.com"
.Update
End With
If strFrom & "" = "" Then strFrom = "Database_Notification@fountaintrust.com"
Set msgOne = CreateObject("CDO.Message")
Set msgOne.Configuration = cdoConfig
With msgOne
.To = strTo
.From = strFrom
.Subject = strSubject
.TextBody = strText
.Send
End With
Set cdoConfig = Nothing
Set msgOne = Nothing
End Sub
The other idea that I had was change it from a sub to a function and use it as a flag of some sort. I would just have to trust that since the email addresses are saved in the database that they are accurate. If there was an error going through the code, then the error handler would set the function to 1. If the function didn't have an error, then the function would return a 0. Is this a valid idea or does it make me worthy of brain surgery to fix the cobwebs in my brain?
Comment