emailing Spreadsheet?

  • Thread starter Thread starter scott
  • Start date Start date
S

scott

I have an access database that spits out an excel file to
my C drive...is there a way that I can have this file
automatically emailed to someone?

I checked the access NG and they said to check here
because the file was now an excel file.

I want to run the access database
It spits out the excel file and automatically emails it to
certain people.

Thanks for all your help.
Scott
 
Hi scott

If you use Outlook??

I think you can use this without any problems in Access VBA


Sub Mail_workbook_Outlook()
'You must add a reference to the Microsoft outlook Library
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
'You can add files like this
.Attachments.Add ("C:\test.xls")
.Send 'or use .Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
 
Thank you for this info..I do have one question..Where do
I put the code and how do I run it? I tried copying it
into a macro and using RUN CODE in macro like this

RUNCODE Mail_workbook_Outlook()

but I got an error.

I am using access 97.

Thank you for all your help.

Scott
-----Original Message-----
Hi scott

If you use Outlook??

I think you can use this without any problems in Access VBA


Sub Mail_workbook_Outlook()
'You must add a reference to the Microsoft outlook Library
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
'You can add files like this
.Attachments.Add ("C:\test.xls")
.Send 'or use .Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)




"scott" <[email protected]> wrote in
message news:[email protected]...
 
The code you must place in a normal module
Did you add a reference to Outlook?

1) Go to the VBA editor, Alt -F11
2) Tools>References in the Menu bar
3) Place a Checkmark before Microsoft Outlook ? Object Library
? is the Excel version number
 
Back
Top