|
To copy file attachments from one Outlook item
to another
You cannot programmatically copy an attachment directly from one Outlook
item to another. You must first save the item as a system file.
Naturally, you'll want to delete that file when you're done. This
code uses the Scripting RunTime's
FileSystemObject to get the user's TEMP folder as a place to
save the files and to perform
deletions. The arguments can be any two Outlook items. You can use
this code in any VBScript or
VBA module.
Note
that it works only with normal file attachments. It can't save
embedded objects or attached Outlook items, which act differently
from regular attached files. It also doesn't check to see if a file
of the same name already exists in the target folder. An enhanced
version of CopyAttachments() that checks for existing files is
available as listing 10.9 in
my book's
sample code (free, registration required)
|