Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jul 2013
    Location
    Blacktown NSW Australia
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Report to Access

    Using Access 2010. (Intermediate VBA User). (I know enough to be dangerous).

    The Problem:

    I have a Report, each page containing an Address Block, an e-mail address, a subreport, and each page is for a different organisation member.

    I wish do attempt the following:-

    1) Depending on whether [EMailFlag] is set to "Yes", send current page of report via e-mail (Outlook 2010) or if set to "No", Print to Printer. (Validation takes care of whether e-Mail ddress field is filled).
    2) There will be two 'pdf' attachements to each e-mail which are static, and common to all recipients. These files will exist in a permanent folder path.


    I currently print the report to Printer and stuff envelopes. But in attempt to save postage, the current project is being considered.


    Is there a way (using code), where I can achieve 1) and 2) above. I dont care if I have to run the process twice, once for eMail and once for Printer.

    Have had a preliminary lo0ok at this and even searched this forum, but cant find an appropriate fit.

    Guidance (or a sample of the code) would be gratefully received.

    Ross
    Last edited by RossPart; 2013-07-11 at 18:09.

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts
    The short answer is yes - and it's been done many times. The simplest approach is to use a macro with the SendObject command, as recommended by eHow. But that approach has several limitations. The more flexible approach is to use Automation to create, customize, and send emails, including attachments using VBA in Access. Our tutorial Automation 101 is pretty dated, but still largely appropriate even with Access 2013. However it doesn't really cover automation of Outlook, so take a look at Automating Outlook from a Visual Basic Application. It doesn't give you everything you need, but is a starter. Do a search on Automating Outlook from Access and you should find a number of good references. The real challenge is to understand the object model of Outlook - Outlook 2010 Object Model is a necessary resource.

    We have created several applications that do that sort of thing. In one case we send out nearly 1000 emails with a customized Excel workbook attached; in another we send out customized emails with one static PDF and one customized PDF attachment. One of the challenges if you have more than 100 or so recipients, is that your email provider may think you are spamming, and limit the number you can send. We've seen that with several ISPs. Hope this helps - post back if you get stuck in some of the code issues. I'll check and see if I can find some sample code that is not proprietary.
    Wendell

  3. The Following User Says Thank You to WendellB For This Useful Post:

    RossPart (2013-07-12)

  4. #3
    New Lounger
    Join Date
    Jul 2013
    Location
    Blacktown NSW Australia
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks Wendell, looks like my weekend is now filled up with reading and research. I am back after a long absence to this forum, and I remember your previous helpful advise. (You may remember me as Devious_Dude, but its been a couple of years).

    Ross
    Last edited by RossPart; 2013-07-12 at 00:12. Reason: Spelling

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •