Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default E-mail Multiple Attachments


Hi All,

I am having trouble figuring out how to E-mail multiple attahcments:

The code works fine when I E-mail one attachment per E-mail address.
However it does not when I try & add another file path.

I reference a cell that has the file path for the attachment ( I use
this because the dates change automatically in the file path name) For
example Cell E2 (C:Book2_December 1.xls)

Below is the code I am using:

Sub SendWithAttach()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim cell As Range

Application.DisplayAlerts = False

Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")

On Error GoTo cleanup
For Each cell In
Sheets("Mail").Columns("B").Cells.SpecialCells(xlC ellTypeConstants)
If cell.Offset(0, 1).Value < "" Then
If cell.Value Like "?*@?*.?*" And Dir(cell.Offset(0,
3).Value) < "" Then
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
..To = cell.Value
..CC = cell.Offset(0, 1).Value
..Subject = cell.Offset(0, 2).Value
..HTMLBody = "Hello " & cell.Offset(0, -1).Value &
"," & SheetToHTML(ThisWorkbook.Sheets(10))
..Attachments.Add cell.Offset(0, 3).Value '&
cell.Offset(0, 5).Value
'.Display
..Send
End With
Set OutMail = Nothing
End If
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True

Sheets("Mail").Select
Range("H1").Select


End Sub



Any help would be greatly appreciated.


--
STEVEB
------------------------------------------------------------------------
STEVEB's Profile: http://www.excelforum.com/member.php...fo&userid=1872
View this thread: http://www.excelforum.com/showthread...hreadid=489979

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default E-mail Multiple Attachments

Hi STEVEB

Repeat this line

Attachments.Add cell.Offset(0, 3).Value
Attachments.Add cell.Offset(0, 4).Value
Attachments.Add cell.Offset(0,5).Value

--
Regards Ron de Bruin
http://www.rondebruin.nl


"STEVEB" wrote in message
...

Hi All,

I am having trouble figuring out how to E-mail multiple attahcments:

The code works fine when I E-mail one attachment per E-mail address.
However it does not when I try & add another file path.

I reference a cell that has the file path for the attachment ( I use
this because the dates change automatically in the file path name) For
example Cell E2 (C:Book2_December 1.xls)

Below is the code I am using:

Sub SendWithAttach()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim cell As Range

Application.DisplayAlerts = False

Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")

On Error GoTo cleanup
For Each cell In
Sheets("Mail").Columns("B").Cells.SpecialCells(xlC ellTypeConstants)
If cell.Offset(0, 1).Value < "" Then
If cell.Value Like "?*@?*.?*" And Dir(cell.Offset(0,
3).Value) < "" Then
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
To = cell.Value
CC = cell.Offset(0, 1).Value
Subject = cell.Offset(0, 2).Value
HTMLBody = "Hello " & cell.Offset(0, -1).Value &
"," & SheetToHTML(ThisWorkbook.Sheets(10))
Attachments.Add cell.Offset(0, 3).Value '&
cell.Offset(0, 5).Value
'.Display
Send
End With
Set OutMail = Nothing
End If
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True

Sheets("Mail").Select
Range("H1").Select


End Sub



Any help would be greatly appreciated.


--
STEVEB
------------------------------------------------------------------------
STEVEB's Profile: http://www.excelforum.com/member.php...fo&userid=1872
View this thread: http://www.excelforum.com/showthread...hreadid=489979



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default E-mail Multiple Attachments


Thanks Ron,

Everything worked great!


--
STEVEB
------------------------------------------------------------------------
STEVEB's Profile: http://www.excelforum.com/member.php...fo&userid=1872
View this thread: http://www.excelforum.com/showthread...hreadid=489979

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
E-mail macro - how do I attach multiple attachments? G and (ajk) Excel Discussion (Misc queries) 1 October 9th 06 01:22 PM
Blocked e-mail attachments LB[_4_] Excel Programming 4 October 1st 05 02:00 PM
Creating TWO-WAY E-Mail Attachments with 'BeforeSave Events' in Code for 2nd E-Mail Chuckles123[_112_] Excel Programming 0 September 8th 05 05:56 PM
E-mail Attachments STEVEB Excel Programming 1 August 23rd 05 02:27 PM
Multiple attachments in Excel e-mail? Peter[_42_] Excel Programming 1 June 12th 04 12:22 PM


All times are GMT +1. The time now is 01:47 AM.

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

About Us

"It's about Microsoft Excel"