Emailing from table data

tweetyksc

Registered User.
Local time
Today, 19:59
Joined
Aug 23, 2001
Messages
87
Hi everyone,

I have a table in Access with user's info for our company's ordering website.

I need to send an email to each person on the list letting them know their login ID and password, include a link to the site, and attach instructions. LOGIN ID, PASSWORD, EMAIL ADDRESS are fields in the table. Obviously, I want to do this through code.

I know how to set up the code to include what I want in the body of the letter; I can figure out how to put a link in there, and attach the zip file with instructions, it's looping through the table that draws me a blank. I had a much larger project that got put to the back burner that I was trying this on and got nowhere.

If anyone can even just point me to some basic instructions on learning how to do this I would be really grateful!
 
Is the web link the same for all recipients?
If so you can set this in code

Don't know how to send a zip file so this is based sending an access report as an rtf attachment.

Dim dbs As DAO.Database,
Dim rst as DAO.Recordset
Dim strEmailAddress As String
Dim strSubject As String
Dim strEMailMsg As String
Dim strWebLink as String

strWebLink ="http://www.Company.com"
stDocName ="MyReportToAtt"
strSubject ="Email Subject Here"

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("MyTable")
rst.MoveFirst
Do Until rst.EOF
strEMailMsg =rst![PersonMame] & chr(10) & chr(10) _
& "Your Login ID = " & rst![Login ID] & chr(10) _
& "Your Password = " & rst![Password] & chr(10) _
& "Company Web link = " & strWebLink & chr(10) _
& "Please find attached further instructions" & chr(10) & chr(10) _
& "Yours etc etc"

strEmailAddress =rst![Email Address]

If Not IsNull(strEmailAddress) Then
'EMAIL USER DETAILS & ATT REPORT
DoCmd.SendObject acSendReport, stDocName, acFormatRTF, strEmailAddress , , , strSubject, strEMailMsg, False, False
End If

rst.MoveNext
Loop
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing

End Sub

-----------------------

NOTES

TEST IT FIRST !
Try this out on a demo table first, including only a few e-mail addresses and inform those recipients they will be receiving an e-mail (maybe more than once!)

You may be better using a query then you can set the [Person Name] field to an 'address type' field, i.e . 'Mr A Smith'.

chr(10) is a return/line feed.

This code is based on DAO 3.6 using A97.

You may get a MS Outlook dialog box pop up for each e-mail sent. Unfortunatley I don't know how to surpress this.

HTH
 
Thanks. I'll test this out.

Alternately, do you happen to know if there is a way in Outlook to do this, i.e. a "mass emailing" to people pulling only their specific info (email address, login info) from a data file?
 
I was just curious...didn't mean to sound ungrateful...
what you posted will help me a lot with this project and to build
on it for others.
Thanks!!
 

Users who are viewing this thread

Back
Top Bottom