Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

thread181-1210112 mask To: field in sendmail code

Status
Not open for further replies.

patrichek

MIS
Nov 18, 2003
632
US
Hi,
can someone help me figure out how to mask the To: field of the recipients i send a bulk email to?

here is my code (by the way using outlook express)

Code:
Function SendMail()
    
    Dim dbs      As DAO.Database
Dim rst      As DAO.Recordset
Dim strSQL   As String
Dim strEmail As String
Dim strbody  As String
Dim strESubject As String

Dim fso As Object
Dim f As Object
Dim ts As Object
    
    ' Return reference to current database.
    Set dbs = CurrentDb
    'Find record to send report of
    strSQL = "SELECT EmailName " & _
             "FROM email2infopromisedtbl"

    Set rst = dbs.OpenRecordset(strSQL)

    If rst.BOF And rst.EOF Then
   rst.Close
   Set rst = Nothing
   Set dbs = Nothing
Exit Function
End If
    
    strEmailname = ""
    Do While Not rst.EOF
      strEmailname = strEmailname & rst("Emailname") & ";"
      rst.MoveNext
    Loop
    strEmail = Left(strEmailname, Len(strEmailname) - 1)
    

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.GetFile("\\ls-server\leads\scripts_etc\emailIP.txt")
    Set ts = f.OpenAsTextStream(1, -2) 'ForReading, TristateUseDefault
    strbody = ts.ReadAll
    ts.Close
    Set ts = Nothing
    Set f = Nothing
    Set fso = Nothing
    strESubject = "Reminder from LSI"

    ' send email.
    DoCmd.SendObject acSendNoObject, "", acFormatTXT, strEmail, , , strESubject, strbody, False

    rst.Close
    Set rst = Nothing
    Set dbs = Nothing

End Function
 
I think if you use CDO you can use 'BCC'. Any interest in this, or are you sold on SendObject?

A wise man once said
"The only thing normal about database guys are their tables".
 
i actually have it inserting an address in BCC but it won't sent the email unless i click the "send" button manually. I guess its because the "To:" field is empty. I've tried adding my email address to the To: field but get a syntax error.

any thoughts what could be wrong here?

Code:
DoCmd.SendObject acSendNoObject, "", acFormatTXT, myemail@home.com, , strEmail, strESubject, strbody, False

thanks!
 
Alex,
thanks for your input, I just needed to at quotes around my email address and now it works.

I had help from the access vba forum on this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top