Attaching Files to Outlook

Status
Not open for further replies.
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("JoeBlow1@dot.com", "JoeBlow2@dot.com"),

Subject:=vNewFileName1 & " !B!A!C!K!U!P!S!"

ActiveWorkbook.Close (False)

MsgBox "Your file has been sent"

Application.StatusBar = "Ready"

Application.DisplayStatusBar = True

JT
 
You'd be better off using the OUtlook Object Model explicitly:

set OlApp = CreateObject("Outlook.Applicartion")

set Msg = OlApp.CreateItem(0)

Msg.To = "JoeBlow1@dot.com; JoeBlow2@dot.com"

Msg.Subject = "Test"

Msg.Attachments.Add "c:\folder\YourFileName.xls"

Msg.Send

Dmitry Streblechenko (MVP)

-

"JT" <JT> wrote in message

news:E5B4F6B8-94B1-44B4-8777-77A9E69C8CED@microsoft.com...
> 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("JoeBlow1@dot.com", "JoeBlow2@dot.com"),
> Subject:=vNewFileName1 & " !B!A!C!K!U!P!S!"

> ActiveWorkbook.Close (False)

> MsgBox "Your file has been sent"

> Application.StatusBar = "Ready"
> Application.DisplayStatusBar = True

> > JT
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
D Attaching date named files Using Outlook 3
R Shortcut for attaching the same file repeatedly Using Outlook 6
M re-Attaching PSTs after upgrade to 2016 Using Outlook 0
P Outlook Randomly Not attaching (attachment file) Using Outlook 0
L Creating a Task from Email and Attaching Original Email Outlook VBA and Custom Forms 6
D Attaching email conversations to tasks Using Outlook 2
A Attaching mail items in Outlook 2010 Outlook VBA and Custom Forms 5
D Tab Order Out of Sequence After Attaching Document Outlook VBA and Custom Forms 1
H attaching e-mails to new e-mail using VBA Outlook VBA and Custom Forms 1
B Outlook 365 Files Being Created with Logging OFF Using Outlook 0
F Outlook 365 Can I attach 2 files to to post? Using Outlook 1
K Protected View - Files fail, no banner Using Outlook 4
R Advise on using multiple instances of network files based on customers Outlook VBA and Custom Forms 8
H Outlook 365 issue getting details from embedded files, crashing routine Outlook VBA and Custom Forms 0
B Outlook 213 keeps crashing. I just found out there are DMP files. How can I tell Why? Using Outlook 2
Commodore MHT files (from "View in browser") Using Outlook 7
J What are .PST.db and .PST.db.journal Files? Using Outlook 2
G Outlook 2016: Want IMAP Data Files on My D: Drive and Not C: Drive Using Outlook 1
D a general question re how backup programs handle pst files ... I have no problems, just curious Using Outlook 1
R Outlook 2010 How do you export 2 email Accounts' 2010 Inbox Files to new computer (2019)? Using Outlook 0
N pst files are recreating automaticaly and cannot be deleted Using Outlook 5
Y Open and Save Hyperlink Files in multiple emails Outlook VBA and Custom Forms 9
C Export NSF Lotus Notes files in Outlook PST format? Using Outlook 1
abnet Advice required re backing up .ost and .pst files Using Outlook 7
R "Can't store Outlook data files under the AppData folder. Please choose another folder." Using Outlook 6
N Two .pst files on one computer both with contacts? Using Outlook 9
V Carbonite not backing up .ost files Using Outlook 7
DoctorJellybean Import accounts\files Using Outlook 1
P Desktop doesn't index Outlook IMAP files, laptop Outlook does index those same IMAP files Using Outlook 2
O Outlook 2016 has "Outlook 2015" files Using Outlook 2
R How can I access my emails from corrupt offline files of MS Outlook ? Using Outlook 1
K Outlook Archive to PST Files by Date Range VBA Script? Outlook VBA and Custom Forms 1
O Any decent tool to compare .pst files? Using Outlook 2
L Need to import multiple Outlook files to Office 365 Account Using Outlook 4
S Dragging Files In Outlook 2016 Using Outlook 6
M Multiple spurious empty folders appear in archive files Using Outlook 3
O Merge .pst files (without structure) Using Outlook 7
C Attached Files outlook 2010 Using Outlook 1
C Attached files on Outlook 2010 Sp1 & Exc 2013 are missing Exchange Server Administration 1
B Delete/replace old files and save new attachments Using Outlook 1
I Outlook 2010, 2013 will not open .msg or .eml files Using Outlook.com accounts in Outlook 1
R Lost PST files after format Using Outlook 6
Diane Poremsky Rename Email Accounts and Data Files in the Folder List Using Outlook 0
LarryS change day template as cpao does not see .catx files Outlook VBA and Custom Forms 4
Kika Melo Change location of Outlook SecureTemporary Files Folder Using Outlook 5
A UID field in iCal files - unique per-event or per-user or both? Using Outlook 2
I Windows 10 - .msg files on disk show Explorer popup error Using Outlook 5
I Not receiving video files sent by iPad Using Outlook 1
B Deleting old Stream_autocomplete and other files Using Outlook 1
fitzgerald Lost PST files after format - how to recover deleted files? Using Outlook 3

Similar threads

Back
Top