Hello Email Help

L

Lee

I am trying to write this code to grab all the emails from a table I set up.
For some odd reason when I am running the code it doesn't populate the emails
in my address field and stops at the first @ sign and cuts all the rest off.

For Example after I run the code
I get this
lee
instead of (e-mail address removed)

Here is the code.

Function sendEmail(recipients As String, subject As String, messageContent
As String) As Integer
DoCmd.SendObject acSendNoObject, , , recipients, , , subject,
messageContent, True
sendEmail = 1
End Function


Function sendEmailToPreparers() As Integer

Dim to_address As String, message As String, subject As String, sSql As
String
Dim emailReturnStatus As Integer
Dim dbs As DAO.Database
Dim rs As Recordset

Set dbs = CurrentDb
sSql = "SELECT email FROM [tbl Preparer]"
Set rs = dbs.OpenRecordset(sSql)

'initialize string
to_address = "_FIRST_"
With rs
If Not .EOF Then
'don't add nulls to the email address
If Not (IsNull(.Fields(0))) Then
'see if we have an email address first
MsgBox (StrComp(to_address, "__FIRST__"))
If (StrComp(to_address, "_FIRST_", vbTextCompare) = 0) Then
to_address = .Fields(0)
Else
'MsgBox (.Fields(0))
to_address = to_address & .Fields(0)
End If
End If
.MoveNext
End If
MsgBox (to_address)
.Close
End With

subject = "Account Reconciliation Tracker Update"
message = "To whom it may concern:" & vbNewLine & vbNewLine
message = message & "The Account reconciliation database has been
updated with new accounts, account balances, and account activity. Feel free
to update your reconciliation tracking information." & vbNewLine & vbNewLine
message = message & "Regards," & vbNewLine & vbNewLine
message = message & "Your friendly Account Reconciliation Tracker Admin"
message = message & to_address

emailReturnStatus = sendEmail(to_address, subject, message)

sendEmailToPreparers = emailReturnStatus

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top