Glenn
A better option might be to loop through the files in a specific folder. The
reason is that you may have files with different extensions and the names may
also change in future, which would require a change in your code.
In this example, you will need to install the references to Windows Script
Host Model (if you do not wish to install it, you will require to create the
scripting object instead):
Sub Example()
Dim oOutlook As Outlook.Application
Dim oEmailItem As MailItem
Dim oFileSystem As New FileSystemObject
Dim oFolder As Object
Dim oFile As File
On Error Resume Next
Set oOutlook = GetObject(, "Outlook.Application")
If oOutlook Is Nothing Then Set oOutlook =
CreateObject("Outlook.Application")
On Error GoTo 0
Set oEmailItem = oOutlook.CreateItem(olMailItem)
Set oFolder = oFileSystem.GetFolder("C:\For Deletion")
With oEmailItem
For Each oFile In oFolder.Files
.Attachments.Add oFile.Path
Next oFile
.To = "(e-mail address removed)"
.Display
End With
Set oFolder = Nothing
Set oFileSystem = Nothing
Set oEmailItem = Nothing
Set oOutlook = Nothing
End Sub
--
Best regards
Robert, Excel MVP
Author of RibbonX: Customizing the Office 2007 Ribbon:
Find me at
http://www.msofficegurus.com - be part of it!
FORUM:
http://www.msofficegurus.com/forum/