M
MDW
Based on a question I had in an Outlook forum, I decided to move to CDO to
send e-mails via Access. However, I'm getting a "type mismatch" error in the
code that I pulled from the MSDN Library. I'm using Access 2003. Below is the
relevant code (error indicated inline).
If it matters, this code is being executed on a standard workstation and not
a server.
Dim objMsg As CDO.Message
Dim objConfig As CDO.Configuration
Dim objField As ADODB.Field
Dim objFields As ADODB.Fields
Set objMsg = New CDO.Message
objMsg.Subject = strSubject
objMsg.TextBody = strMessage
objMsg.From = "(e-mail address removed)"
objMsg.To = objAdmin(1).Value
' Set configuration.
Set objConfig = New CDO.Configuration
Set objFields = objConfig.Fields << TYPE MISMATCH
objField =
objFields("http://schemas.microsoft.com/cdo/configuration/sendusing")
objField.Value = 1 ' Sets the configuration to use the local SMTP server
objFields.Refresh
objMsg.Configuration = objConfig
objMsg.Send
Set objMsg = Nothing
send e-mails via Access. However, I'm getting a "type mismatch" error in the
code that I pulled from the MSDN Library. I'm using Access 2003. Below is the
relevant code (error indicated inline).
If it matters, this code is being executed on a standard workstation and not
a server.
Dim objMsg As CDO.Message
Dim objConfig As CDO.Configuration
Dim objField As ADODB.Field
Dim objFields As ADODB.Fields
Set objMsg = New CDO.Message
objMsg.Subject = strSubject
objMsg.TextBody = strMessage
objMsg.From = "(e-mail address removed)"
objMsg.To = objAdmin(1).Value
' Set configuration.
Set objConfig = New CDO.Configuration
Set objFields = objConfig.Fields << TYPE MISMATCH
objField =
objFields("http://schemas.microsoft.com/cdo/configuration/sendusing")
objField.Value = 1 ' Sets the configuration to use the local SMTP server
objFields.Refresh
objMsg.Configuration = objConfig
objMsg.Send
Set objMsg = Nothing