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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help hiding the To: fields in email code 1

Status
Not open for further replies.

patrichek

MIS
Nov 18, 2003
632
US
Hi, I have some code that take email addresses from a table and inserts them into a reminder email we send out to our patients.
The problem is I need to hide the email addresses so they are not listed for all the receivers to see. I searched the forum but can't find any code that is like mine.
here's my code:

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("\\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 had alot of help building this code and I'm afraid to break it by changing something.....

thanks!
 
What email address are you trying to hide? Yours, the recipients? It doesn't look like you are doing a CC to a large number of people, when i do that i always do a BCC

Mark P.
Providing Low Cost Powerful Point of Sale Solutions.
 
I'm trying to hide the recipients addresses, sorry for not clarifying that.

I get the email addresses from a column in a table
Code:
strSQL = "SELECT EmailName " & _
             "FROM email2infopromisedtbl"

by the way i use outlook express for sending.
thanks!
 
When this code runs it opens outlook, inserts a bunch of email addresses from a table into the "To:" field then is emailed. When the patient receives the email he can see the names of everyone the email has beeen sent to.

We are a healthcare clinic and its against the law (HIPAA) to share patient data with anyone.

 
I'm well aware of HIPPA, I don't think they have done anything to anyone ever... just a buercratic bunch of !#! anyways. I wrote an application for DME Dealers.

when you go into your vba code, you can type in

docmd.sendobject

so you don't mess up your code, simply back up your application, or the procedure itself.

if you press the space key, you'll see a list of parameters that you can input. each time you hit a comma you'll be prompted for the next, you'll see that one of them is BCC. BCC is blind carbon copy, cc is carbon copy (everyone sees the emails), place your emails in the blind carbon copy.

I like to send mass emails to myself. So i put my own email in my address so i can seet hat everything went out correctly. Try it and let me know.

DoCmd.SendObject acSendNoObject, "", acFormatTXT, strEmail, , <insert emails here> , strESubject, strbody, False


Mark P.
Providing Low Cost Powerful Point of Sale Solutions.
 
One way:
Code:
DoCmd.SendObject acSendNoObject, "", acFormatTXT, , , strEmail, strESubject, strbody, False
instead of
Code:
DoCmd.SendObject acSendNoObject, "", acFormatTXT, strEmail, , , strESubject, strbody, False
i.e. send it to the BCC (blind carbon copy)

But I would simply loop through the list and call SendObject n times to 1 recipient each, because I tend to ignore stuff that is sent via bcc.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
traingamer,

I like your way using:
Code:
DoCmd.SendObject acSendNoObject, "", acFormatTXT, , , strEmail, strESubject, strbody, False

when i ran the code it opened the email, inserted the address in the BCC field, but did not send until i manually clicked send. is there a way around this?

thanks!
 
Don't use SendObject myself. You might try Mark's suggestion and send it to yourself and blind copy the real recipients. (It may need a "to:" field.) i.e.
Code:
DoCmd.SendObject acSendNoObject, "", acFormatTXT,[COLOR=blue]youremail@zz.com[/color] , , strEmail, strESubject, strbody, False

From a 'spam' perspective, your method would never get past my email filters and into my inbox, but most people aren't as picky.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Traingamer,

i keep getting a compile error when i try to input my email address in the "to" field. I copied your post exactly and input my email addy in place of the fake one.
I've also tried adding to: and mailto:in front of the address with and without the colon and space and no luck....?

we're getting close though!
any other suggestions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top