Attaching Files to Outlook

  • Thread starter Thread starter JT
  • Start date Start date
J

JT

I have an Excel macro that saves a workbook and sends it to a user at a
specific cost center. Part of the code I am using is below.

I have a new requirement that other cost centers would like to attach backup
files to support the Excel file that gets sent in the e-mail.

I'm looking for some code or suggestions that will allow me to attach the
other files to the e-mail before it is sent. I will have the paths to each
backup file in a array.

Is this possible? Thanks for the help

ActiveWorkbook.SaveAs (vPath & vNewFileName)

On Error GoTo errmsg

ActiveWorkbook.SendMail Array("(e-mail address removed)", "(e-mail address removed)"),
Subject:=vNewFileName1 & " !B!A!C!K!U!P!S!"

ActiveWorkbook.Close (False)

MsgBox "Your file has been sent"

Application.StatusBar = "Ready"
Application.DisplayStatusBar = True
 
You'd be better off using the OUtlook Object Model explicitly:

set OlApp = CreateObject("Outlook.Applicartion")
set Msg = OlApp.CreateItem(0)
Msg.To = "(e-mail address removed); (e-mail address removed)"
Msg.Subject = "Test"
Msg.Attachments.Add "c:\folder\YourFileName.xls"
Msg.Send

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
Back
Top