Help with automated email (1 Viewer)

outofpractice

Registered User.
Local time
Today, 13:17
Joined
May 10, 2011
Messages
32
OK - we have a person leaving our department in a couple weeks and one of the tasks she does is coming to me. Basically what this task is is: she has a list of about 30 people that she emails quarterly to remind them to review their content on the website. Each person's email has links to their specific pages to review. The way she does it is she has drafts for each person and copies/pastes each quarter from the draft and emails the person. I really do not want to do that - I would like to just set something up automated to remind these people to review their pages. My initial thought was to try and use Lotus Notes to do this, but I think my IT staff has that function shut off because I tried the: Create -> Agent but nothing happens (maybe there was another way to go about this?

Anyhow - so my next thought was to just load up into an Access database all of the contacts, their emails, and their pages - I would then be able to email them with a button press. I think that I am about there but am running into problems with the VB (I am not programmer, I've been able to cobble together what I have with some research and looking at others work).

So all that I have are two tables - one with Contact Name/Email Address and table with Page Name, Page Link, and Owner (Contact Name)

I set up a form (based on a query) that when opened, record 1 will show:

John Smith and in a sub-form all of the pages which he ownes. I then have a button on the page to generate the email. I have that part working - email is sent to the email pulled for the owner just fine - the problem is if the person owns multiple pages, I am only sending the first record. What I have been trying to figure out is how to have the VB create the email and return all of the pages that are associated with the person (hope that explination makes sense).

What I have is:


Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim session As Object
Dim db As Object
Dim doc As Object
Dim intUserResponse As Integer
Dim recipient(3) As Variant
Dim recipCC(2) As Variant
recipient(0) = [Contact_Email].Value
recipCC(0) = "myemail@address"
Set session = CreateObject("Notes.NotesSession")
Set db = session.GETDATABASE("", "")
Call db.OPENMAIL
Set doc = db.CREATEDOCUMENT()
doc.Form = "Memo"
doc.Subject = "Quarterly Page Review "

doc.body = [qry_Page_Query subform]![Page_Title].Value

doc.SendTo = recipient
doc.CopyTo = recipCC
Call doc.SEND(False)
DoCmd.GoToRecord , , acNext
Exit_Command8_Click:
Exit Sub
Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End Sub

The line I have above in Red is where the Page information is being pulled from and I need to have it pull however many records are on the sub-form.

DB is very basic:

Tables:
tbl_Contact
tbl_Page

Query
qry_Page_Query

Forms
frm_Information
qry_Page_Query subform

I hope I have explained sufficiently and given enough information for some assistance. Thanks!
 

billmeye

Access Aficionado
Local time
Today, 16:17
Joined
Feb 20, 2010
Messages
542
You might consider just making a Module with the needed code and placing it behind a button that will cycle through all records on both tables or a query with reduced records. I'm using code (Docmd.SendObject) to use a built in mail program like Outlook or Thunderbird etc. If you are using something else, substitute your e-mail code.

Code:
Dim Rs as DAO.Recordset, subRs as DAO.Recordset
Dim TheMessage as String, MySQL as String
Set Rs = CurrentDb.OpenRecordset("tbl_Contact", dbOpenDynaset)
Rs.MoveLast
Rs.MoveFirst
Do While Not Rs.EOF 
    MySQL = "SELECT * FROM tbl_Page WHERE(((tbl_Page.ContactID)=" & Rs!ContactID & "));"
    Set subRs = CurrentDb.OpenRecordset(MySQL, dbOpenDynaset)
    subRs.MoveLast
    subRs.MoveFirst
    Do While Not subRs.EOF
    TheMessage = subRs!WebPage 'and whatever else you want 
    DoCmd.SendObject acSendNoObject,,,Rs!Contact_Email,"myemail@address","Quarterly Page Review",TheMessage ,True 'True if you want to edit, False to just send
    subRs.MoveNext
    Loop
    subRs.close
    Set subRs = Nothing
Rs.MoveNext
Loop
Rs.close
Set Rs = Nothing
 

Users who are viewing this thread

Top Bottom