deharris2003
Programmer
I continue to get a type mismatch error and I cannot seem to understatnd why. I am calling this function from a macro. Any help is much appreciated. Here is my code
Function SendMail(expr1 As String, strMessage As String)
Dim dbs As Database 'Holder for database to be updated
Dim rst As Recordset 'Create recordset called rst
Dim strSQL As String 'Holder for SQL statement
Dim strHP As String 'Holder for Helath Plan Name
Dim strEmail As String 'holder for email name
Dim strbody As String 'Holder for Message Body
' Return reference to current database.
Set dbs = CurrentDb
'Find record to send email to
strSQL = "SELECT Name, Email " & _
"FROM Email"
Set rst = dbs.OpenRecordset(strSQL)
Do While Not rst.EOF
strHP = expr1
strEmail = rst("Email"
If strMessage = "Done" Then
strbody = vbCrLf & vbCrLf & _
"Please note that " & strHP & " has been updated on the web."
ElseIf strMessage = "Start" Then
strbody = vbCrLf & vbCrLf & _
"Please note that " & strHP & " is in the process of being updated." & vbCrLf & _
"We apoligize for this inconvience. You will recieve an email when" & vbCrLf & _
"This process is completed."
End If
' send email.
DoCmd.SendObject acSendNoObject, "", acFormatTXT, strEmail, , , strHP, strbody, False
rst.MoveNext
Loop
End Function
Function SendMail(expr1 As String, strMessage As String)
Dim dbs As Database 'Holder for database to be updated
Dim rst As Recordset 'Create recordset called rst
Dim strSQL As String 'Holder for SQL statement
Dim strHP As String 'Holder for Helath Plan Name
Dim strEmail As String 'holder for email name
Dim strbody As String 'Holder for Message Body
' Return reference to current database.
Set dbs = CurrentDb
'Find record to send email to
strSQL = "SELECT Name, Email " & _
"FROM Email"
Set rst = dbs.OpenRecordset(strSQL)
Do While Not rst.EOF
strHP = expr1
strEmail = rst("Email"
If strMessage = "Done" Then
strbody = vbCrLf & vbCrLf & _
"Please note that " & strHP & " has been updated on the web."
ElseIf strMessage = "Start" Then
strbody = vbCrLf & vbCrLf & _
"Please note that " & strHP & " is in the process of being updated." & vbCrLf & _
"We apoligize for this inconvience. You will recieve an email when" & vbCrLf & _
"This process is completed."
End If
' send email.
DoCmd.SendObject acSendNoObject, "", acFormatTXT, strEmail, , , strHP, strbody, False
rst.MoveNext
Loop
End Function