
Access report to Outlook/ Open Outlook and mail report
It sounds like you have the Access part down but need some help with
Outlook. To create a new mail item in Outlook you need to set a
reference to the Outlook object model and create the following
objects: Application, Namespace, Mapifolder and MailItem. At that
point you are almost home free. I assume you are outputting your
access report to some common format. I have tested the following
example by outputting a report to an html format with the following
code (done within Access):
DoCmd.OutputTo acOutputReport, "LawsuitLog", acFormatHTML,
"C:\Goodies\AcCessReport.html", False
The following code will send this report to an e-mail recipient (note,
you can also send just a shortcut if the report is on a network
accessible by your recipient. If so, replace olByValue with
olByReference):
Option Explicit
Private Sub Command1_Click()
Dim OL As Outlook.Application
Dim OLNS As Outlook.NameSpace
Dim MailFolder As Outlook.MAPIFolder
Dim MyMail As Outlook.MailItem
Set OL = New Outlook.Application
Set OLNS = OL.GetNamespace("MAPI")
Set MailFolder = OLNS.GetDefaultFolder(olFolderInbox)
Set MyMail = MailFolder.Items.Add
With MyMail
.Subject = "Here is that Access Report"
.Body = "The following report has been attached: "
.Attachments.Add "C:\Goodies\AccessReport.html", olByValue, 1,
"Access Report"
.Save
.Send
End With
OL.Quit
Set OL = Nothing
Set OLNS = Nothing
Set MailFolder = Nothing
Set MyMail = Nothing
End Sub
Keep in mind you may be in a mixed environment with Outlook 97 and 98
clients. If these clients are sending the reports, you may need to
late bind these objects and I recommend using the msoutl8 library, not
msoutl85 just to make sure you are not trying to automate something
not available in Outlook97.
Good luck with your projects and feel free to e-mail me if you have
any questions regading the above.
-Dan Beacom
End Sub
Quote:
>> I need to take a report from Access and based on the vendor name
>> open Outlook and mail the report to correct address which would be stored
>in
>> a table.
>...minor snipping...
>> Any ideas. I guess what I really need is to understand
>> the object properties in Outlook.
>> Please email rather than post.
>For what it's worth, I have to come up with something similar for our
>internal customers within the company and would appreciate it if someone
>could post the answer as well as emailing Bill. Many thanks in advance.
>Ed