General discussion

  • Creator
  • #2298064

    Access and Auto e-mail


    by andyn ·

    Greetings All

    Here’s my problem. I need to automatically e-mail files as attachments.
    The problem is that the file locations are stored in the results of an Access 97 query, I need some way of interogating the results and pick up the file names and e-mail addresses to which to send them. This would need to run every day at the same time automatically.
    My Access knowledge is limited so weather this is a plug in option or not I have no idea. Or even if it’s possible.


All Comments

  • Author
    • #2744330

      Reply To: Access and Auto e-mail

      by it_cowboy ·

      In reply to Access and Auto e-mail

      This is certainly possible, however there is no plugin or wizard that I am aware of that will assist you with this. You would need to engage someone with advanced MS Access programming skills and have something specifically written.

    • #2742264

      Reply To: Access and Auto e-mail

      by timfox ·

      In reply to Access and Auto e-mail

      Andy – it’s time to step up. Your question involves a reasonable bit of programming, but here goes…

      Don’t worry about the timing of these events. Let’s just say that you want Access to run the query and send the emails when you click a certain button on a form. OK – now put this code behind the button’s OnClick event:

      Private sub cmdThisButton_OnClick
      dim strEmailStuff as string
      dim rstEmailStuff as recordset

      strEmailStuff = “SELECT EmailAddress, FileLocation from tblThisTable”
      set rstEmailStuff = currentdb.openrecordset(strFileName)
      if rstEmailStuff.recordcount > 0 then
      While rst.EmailStuff not EOF
      SendEmailToWith rstEmailStuff.fields(“EmailAddress”) rstEmailStuff.fields.(“FileLocation”)
      end if
      set rstEmailStuff = nothing

      OK – now you have to define the content of the ‘SendEmailToWith’ function, like this

      Private function SendEmailToWith (strEmailTo as string, strFileAttachment as string)

      End function

      To fill the middle bit – have a look at the following web site and use the code already developed for sending email from MS Access:
      …or use the SendMail function if you really want to. We can get to the “run every day at the same time automatically” another time. Just try to get the button working.

      All the best.

Viewing 1 reply thread