Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 2
Default Sending email with multiple attachments

I found information to send an email with attachments using an excel spreadsheet. It is working perfectly. I now need to update it so that I can add multiple attachments. The documents reside in columns c:m. Any ideas?

Sub Test()
Dim ExcelObject As Object
Dim OutlookApp As Outlook.Application
Dim NewMessage As Outlook.MailItem
Dim OutlookNamespace As Outlook.NameSpace
Dim fName, fLoc, eAddress As String
Dim fNameAddress, fLocAddress, eAddressAddress As String
Dim strHTMLBody As String


' Set up the spreadsheet you want to read
On Error Resume Next
Set ExcelObject = GetObject(, "Excel.Application")
If Not Err.Number = 0 Then
MsgBox "You need to have Excel running with the appropriate spreadsheet open first", vbCritical, "Excel Not Running"
End
End If

' Read in the data and create a new message with attachment for each Excel entry
CellRow = 1
Set OutlookApp = Outlook.Application
Do Until ExcelObject.Range(fNameAddress) = ""
fNameAddress = "A" & CellRow
eAddressAddress = "B" & CellRow
fLocAddress = "C" & CellRow
fName = ExcelObject.Range(fNameAddress)
fLoc = ExcelObject.Range(fLocAddress)
eAddress = ExcelObject.Range(eAddressAddress)
fName = fLoc & "\" & fName
Set OutlookApp = Outlook.Application
Set NewMessage = OutlookApp.CreateItem(olMailItem)
Set myAttachments = NewMessage.Attachments
myAttachments.Add fLoc
With NewMessage
.Recipients.Add eAddress
.Attachments = fLoc
.Display
.Subject = "Action Required: FY13 Budget Development Form"
.HTMLBody = strHTMLBody
strHTMLBody = "<br<FONT FACE=TAHOMA Attached find your school's budget form.
' .Send
End With
CellRow = CellRow + 1
fNameAddress = "A" & CellRow
Loop
End Sub
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Macros sending attachments to multiple e-mail addressescontained in one cell. [email protected] Excel Programming 2 January 19th 08 02:01 AM
Code for sending Outlook email with attachments using a list craig Excel Programming 1 December 13th 07 10:48 PM
Can I save multiple email attachments using excel automatically? ir26121973 Excel Programming 13 March 18th 06 06:54 PM
sending a workbook by email to multiple recipients keepitcool Excel Programming 6 September 4th 03 11:56 AM


All times are GMT +1. The time now is 08:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"