Attach all files in a folder using Code

CBragg

VB Dummy
Local time
Today, 10:55
Joined
Oct 21, 2002
Messages
89
I am trying to attach all files in a folder and send them via email using code. I know the hard code to send the actual email, and when specifiying an actual file name i can attach it. Because the file names i want are named differently on various versions of windows i wish to attach all files within a certain folder.

i am using: SendEmail.Attachments.Add "C:\Test\*.*"

The code doesnt recognise the wildcards, does anyone know how to do this??

Any help would be greatly appreciated.

Thanks.
 
I haven´t used the sendemail stuff, so I don´t know how it works, but maybe you could add all files individually, using a loop?
In that case, look up the dir() function.

Fuga.
 
Sorry, this probably wont work im afraid because i'll still need to specifiy a file name which i cant do.

It will work, however, if i can find out how to specify a wildcard within the directory.

e.g. C:\Test\*.*

Do you have any ideas??
 
Sorry, no.

I thought you could use the dir() to fetch the filenames. If that won´t work then I don´t know. :(

Fuga.
 
Im not familiar with Dir(), could you maybe emphasise on this and i'll give it a go.


Thanks for your help.
 
Ok, my suggestion would be something like this, but I must point out that I´m no VBA guru:


Dim Nextattachment as string

Nextattachment = Dir("c:\yourdirectories\*.*")
Do While Nextattachment <> ""
sendemail.attachments.add nextattachment
nextattachment = dir()
Loop

Fuga.
 
Cheers for that,

Still stuck though in that sence, didnt pick it up as i would have liked. I have come up with an alternative though. Decided to rename them to a standard filename using a batch file.

Thanks anyway

Chris.
 

Users who are viewing this thread

Back
Top Bottom