Is this possible ?

  • Thread starter Thread starter Robert Gillard
  • Start date Start date
R

Robert Gillard

I have a program that runs overnight and finishes by updating a a Excel
spreadsheet.

I would like this updated spreadsheet automatically emailed to 3 people so
it is ready and waiting for them when they arrive for work.

That's what I would like to happen, is it possible .. if so how can I do it.
Can anybody point me in the right direction please ( I am using Excel 2003
and Outlook 2003)

I feel sure others must have gone down this route

Bob
 
Bob,

Here is some code that does it. You should save the workbook before using
this as attachmenst are retrieved from the HDD, not memory. Change the text
bits and email addresses to suit. Invoke like

SendWb Activeworkbook.FullName

Sub SendWb(wb As Workbook)

Dim oOutlook As Object
Dim oMailItem As Object
Dim oRecipient As Object
Dim oNameSpace As Object

Set oOutlook = CreateObject("Outlook.Application")
Set oNameSpace = oOutlook.GetNameSpace("MAPI")
oNameSpace.Logon , , True

Set oMailItem = oOutlook.CreateItem(0)
Set oRecipient = _
oMailItem.Recipients.Add("(e-mail address removed)")
oRecipient.Type = 1
Set oRecipient = _
oMailItem.Recipients.Add("(e-mail address removed)")
oRecipient.Type = 1
Set oRecipient = _
oMailItem.Recipients.Add("(e-mail address removed)")
oRecipient.Type = 1
With oMailItem
.Subject = "The extract has finished."
.Body = "This is an automatic email notification"
.Attachments.Add (wb.FullName)
.Send
End With

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top