Try this one
I use MultiSelect in the code now and loop through the array
Sub Test()
Dim iMsg As Object
Dim iConf As Object
Dim strbody As String
Dim FName As Variant
Dim N As Long
'Dim Flds As Variant
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
' iConf.Load -1 ' CDO Source Defaults
' Set Flds = iConf.Fields
' With Flds
' .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
' .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "Fill in your SMTP server here"
' .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
' .Update
' End With
strbody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4"
With iMsg
Set .Configuration = iConf
.To = "
.CC = ""
.BCC = ""
FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls", _
MultiSelect:=True)
If IsArray(FName) Then
For N = LBound(FName) To UBound(FName)
.AddAttachment (FName(N))
Next
End If
.From = """Ron"" "
.Subject = "Important message"
.TextBody = strbody
.Send
End With
--
Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm
"Gina K" wrote in message ...
That works great - thanks!
As a follow up question: if I want to attach multiple files, would I use an
FName2, FName3, etc., or is there a better way?
"Chip Pearson" wrote:
You can prompt the user for the full file name with one dialog:
Dim FName As Variant
FName = Application.GetOpenFilename()
If FName = False Then
' user cancelled
Exit Sub
End If
Now, you have the complete file name in the variable FName which you can use
to attach the file.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)