Hello everyone, and thank you in advance for any assistance you can
provide with this query.
I've been trying to put together a script which when run will create an
e-mail message and attach all the files residing in a specific folder.
However, currently I'm getting an error and was hoping for some insight
and suggestions.
The script looks like this ....
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set fso = CreateObject("Scripting.FileSystemObject")
Set myfolder = fso.GetFolder("C:\emailfolder\")
Set myfiles = myfolder.files
myItem.Subject = "This is the Subject"
Set myRecipient = myItem.Recipients.Add("myemail@myemail.co.uk")
Set myAttachments = myItem.Attachments
For Each MyFile in MyFiles
myAttachments.Add files(MyFile.Name), olByValue
Next
myItem.Display
I get a scripting error on Line: 10, Char: 3, Error: Type mismatch:
'files' which I'm assuming is referring to the files(MyFile.Name)
section of the script.
I originally produced the script with just a single attachment and this
was fine but upon inserting the code to look to add all the files in
the 'emailfolder' location then the error appeared.
Any suggestions would be most appreciated.
Darren Hermes
darreninwarrington at hotmail dot co dot uk