acess and outlook

  • Thread starter Thread starter Francis Gaudreau
  • Start date Start date
F

Francis Gaudreau

Hi,

is it possible to write a macro/sub/module that would at a specified
date, automaticly send an access report by email to somebody?

Thanks
 
Francis,

Yes, you could do this either with a macro or a VBA procedure. With a
macro, you could use a SendObject action. As for making it happen on a
specified date, you will need to use a Condition in the macro, and you
will need to decide how the sending of the email will be triggered. If
the database will be opened on the day in question, you could assign the
macro on the Open event of a form which is always opened when the
database is, or some such. If it won't be, you could use Windows Task
Manager or some other scheduling software, to run the macro. If this is
the approach you take, the command line syntax will probably be like this...
"C:\PathToAccess\Msaccess.exe" "C:\PathToDB\MyDB.mdb" /x YourMacro
 
Francis:

What Steve suggests will work fine for most cases. My application required
me to export (transfertext) a fixed-width text file & then email it. I
setup a macro which opens a form that includes my VBA code in the open
event. The last item I coded was "docmd.quit" (which will close the db).
If you are planning on using a VBA procedure, use the following code:

Use the code below from Arvin Meyer to send the attachment.
Private Sub Command0_Click()
'Arvin Meyer 03/12/1999
'Updated 7/21/2001
On Error GoTo Error_Handler

Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

With objEmail
.To = "(e-mail address removed)"
.Subject = "Look at this sample attachment"
.body = "The body doesn't matter, just the attachment"
.Attachments.Add "C:\Test.htm"
'.attachments.Add "c:\Path\to\the\next\file.txt"
.Send
'.ReadReceiptRequested
End With

The security dialogs that pop up when an application tries to access Outlook
designed to inhibit the spread of viruses. Try this freeware to auto click
the Yes (http://www.express-soft.com/mailmate/clickyes.html)

One item to watch for - make sure you have "Microsoft Outlook" checked as
one of your references.

Hope this helps!

Craig Schmuck
 
Thanks Yip,

that looks perfect. Last question, you didn't describe how to produce
the report.

thanks
 
Back
Top