Solved

I need help emailing letters to individual email addresses

Posted on 2010-08-12
9
570 Views
Last Modified: 2013-11-28
I need to preface this message by saying that while I have a lot of experience creating databases and working with macros, I have next to no experience with VB coding so any help I receive I really need specific help doing what I need to.Basically, I have a database where I run a report that is basically an hours status letter that runs for customers based on some criteria of number of hours remaining and activity in a month.  The result is a report that contains several letters, one for each customer and I am currently printing the entire report, parsing out each customer's report and mailing it.What I would like is an automated way to generate each customer's letter and email is a pdf attachment.  I have gone through various other threads and have seen references to recordsets and looping but due to my novice status, I am unable to figure out how to apply this information to my database and integrate it in. I understand this is a novice question and that anybody who responds will need to give me some handholding to walk me through how to get this code in and how to customize it with my database.  Thanks very much, any help is greatly appreciated.
0
Comment
Question by:nomi1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
9 Comments
 
LVL 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 125 total points
ID: 33424663
Without going into a ton of detail, this sounds like the sort of thing Word's Mail Merge was made for.  Word is content to use Access as the data source and Outlook as the delivery mode for a Mail Merge.
0
 
LVL 10

Expert Comment

by:t_hungate
ID: 33425326
nomi1

When you get a chance checkout this article, you can probably skip the first portion of it since you said you have been creating DBs for  while now.  But i may be a good starter for you see how and where the VBA portions start to come into it.

http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_3560-Beginners-How-to-utilize-an-Experts-solution-in-the-VBA-editor-with-MS-Access.html?sfQueryTermInfo=1+30+beginn

TLH
0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 125 total points
ID: 33425635
The thing here is that you cannot simply Email a report, you have to specify a format
(RTF, XLS, PDF, ...ect)

You did not specify your version of Access.
The is important because, in order to create a PDF, you will need an External utility for Access 2003 and older.
You will need to PDF Addin installed for Access 2007 and newer.

Here is a sample of both:
Access 2003 an older, PDF and RTF
Access 2007 PDF and rtf

I am sure with your experience you will be able to read through the code and tweak/troubleshoot it to work in your database.

;-)

JeffCoachman


Access-EmailBulkIndividualCustom.mdb
Access--EmailIndividualCustomerR.accdb
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33425676
Oh,

I just read the expert post.

Yes, if you have not the Skills to use VBA, then the Word route might be an easier option.
So give that a try first.

If you plan on posting more questions here requiring code solutions, then you should pick up a good reference book.
Here are a few:
http://www.amazon.com/Microsoft-Access-Programming-Absolute-Beginner/dp/1598633937/ref=sr_1_1?ie=UTF8&s=books&qid=1281655548&sr=8-1
http://www.amazon.com/Access-2007-VBA-Bible-Data-Centric/dp/047004702X/ref=sr_1_27?ie=UTF8&s=books&qid=1281655606&sr=8-27

You can goole for more...

;-)

JeffCoachman
0
 
LVL 31

Assisted Solution

by:Helen Feddema
Helen Feddema earned 125 total points
ID: 33438219
Here is some code to save filtered reports as PDFs and email each to the appropriate address:
Option Compare Database
Option Explicit


Private dbs As DAO.Database
Private qdf As DAO.QueryDef
Private rst As DAO.Recordset


Public Sub SendInterventionEmails()
'Created by Helen Feddema 10-Jan-2010
'Last modified by Helen Feddema 10-Jan-2010

On Error GoTo ErrorHandler

   Dim appOutlook As New Outlook.Application
   Dim itm As Outlook.MailItem
   Dim rstIntervention As DAO.Recordset
   Dim lngCount As Long
   Dim lngID As Long
   Dim rpt As Access.Report
   Dim strFileName As String
   Dim strPrompt As String
   Dim strQuery As String
   Dim strRecordSource As String
   Dim strReport As String
   Dim strSQL As String
   Dim strTitle As String
   Dim strCurrentPath As String
   Dim strFileNameAndPath As String
   Dim strEmailSource As String
   
   strEmailSource = "qryInterventionEmail"
   strRecordSource = "qryMissingAssignments"
   strQuery = "qryMissingAssignmentsSingleStudent"
   Set dbs = CurrentDb
   Set rstIntervention = dbs.OpenRecordset(strEmailSource)
   strCurrentPath = Application.CurrentProject.Path & "\"
   
   'Use path selected with SelectFolder procedure
   'strCurrentPath = SelectFolder()

   With rstIntervention
      Do While Not .EOF
         lngID = ![StID]
         Debug.Print "Processing Student ID " & lngID
         strFileName = "Intervention Report for " & ![StFirst] _
            & " " & ![StLast] & ".pdf"
         strFileNameAndPath = strCurrentPath & strFileName
         
         'Create filtered query
         strSQL = "SELECT * FROM " & strRecordSource & " WHERE " _
            & "[StID] = " & Chr(39) & lngID & Chr(39) & ";"
         Debug.Print "SQL for " & strQuery & ": " & strSQL
         lngCount = CreateAndTestQuery(strQuery, strSQL)
         Debug.Print "No. of items found: " & lngCount
         If lngCount = 0 Then
            GoTo NextStudent
         End If
      
         'Open report with filtered query record source
         strReport = "rptMissingAssignmentsNew"
         DoCmd.OpenReport ReportName:=strReport, _
            View:=acViewPreview, _
            windowmode:=acWindowNormal
         Set rpt = Reports(strReport)
         DoCmd.OutputTo objecttype:=acOutputReport, _
            objectname:=strReport, _
            outputformat:=acFormatPDF, _
            outputfile:=strFileNameAndPath
         
         'Create email
         Set itm = appOutlook.CreateItem(olMailItem)
         itm.Subject = "MISSING WORK"
         itm.Body = "The attached file lists your missing assignments"
         itm.To = ![Email]
         itm.Attachments.Add Source:=strFileNameAndPath, _
            Type:=olByValue
         
         'For editing before sending
         itm.Display
         
         'For sending automatically
         'itm.Send
         DoCmd.Close objecttype:=acReport, _
            objectname:=strReport, _
            Save:=acSaveNo

NextStudent:
         .MoveNext
      Loop
   End With
   
ErrorHandlerExit:
   Exit Sub

ErrorHandler:
   MsgBox "Error No: " & Err.Number _
      & " in SendInterventionEmails procedure; " _
      & "Description: " & Err.Description
   Resume ErrorHandlerExit

End Sub

Public Function CreateAndTestQuery(strTestQuery As String, _
   strTestSQL As String) As Long
'Created by Helen Feddema 28-Jul-2002
'Last modified by Helen Feddema 10-Jan-2010

On Error Resume Next
   
   'Delete old query
   Set dbs = CurrentDb
   dbs.QueryDefs.Delete strTestQuery

On Error GoTo ErrorHandler
   
   'Create new query
   Set qdf = dbs.CreateQueryDef(strTestQuery, strTestSQL)
   
   'Test whether there are any records
   Set rst = dbs.OpenRecordset(strTestQuery)
   With rst
      .MoveFirst
      .MoveLast
      CreateAndTestQuery = .RecordCount
   End With
   
ErrorHandlerExit:
   Exit Function

ErrorHandler:
   If Err.Number = 3021 Then
      CreateAndTestQuery = 0
      Resume ErrorHandlerExit
   Else
   MsgBox "Error No: " & Err.Number _
      & " in CreateAndTestQuery procedure; " _
      & "Description: " & Err.Description
   End If
   
End Function

Open in new window

0
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 33438229
My ebook Working with Word may also be helpful.  It updates some of the examples in my Access 2007 VBA Bible book, and adds some new examples.
0
 
LVL 10

Accepted Solution

by:
Luke Chung earned 125 total points
ID: 33582946
If you're not a coder and want to use a solution that runs as an Access add-in, our Total Access Emailer program, http://www.fmsinc.com/MicrosoftAccess/Email.asp, will do what you seek.

Total Access Emailer will take a table with a list of email addresses and let you filter reports based on values in your table to send emails with PDF reports specifically for each contact.

Your messages can be in text or HTML. The HTML messages can include embedded graphics, and the messages can automatically use fields from your table so each message and subject can be personalized.

Best of all, you don't need to do any programming for all of these features.

A free demo is available for you to try it out.  Good luck.
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 36157638
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question