Copy Attachments

  • Thread starter Thread starter Won Lee
  • Start date Start date
W

Won Lee

Hello,

I'm not familiar with programming Outlook but I am familiar with VB.

Every morning I get an email with several attachments from a specific
email. I would like Outlook to

a) create a directory, named today's date, in my Y:\drive.

b) Copy all attachments

Can this be done? Not looking for the code. Just a tutorial that will
point me in the correct direction.
 
Hi Won,

the OOM doesn´t support a method for creating the directory. You can use
a Win32 API method (CreateDirectory) or the Scripting runtime
(scrrun.dll). I´d recommend the Win32 API.

For handling the incoming e-mail OL provides you with the Inbox item´s
ItemAdd event (a sample is available via the Object Browser).

Depending on the OL version you can check the SenderEmailAddress (OL
2003) or need an additionaly library (CDO 1.21, optional installation
from OL-/Office-CD) for getting the e-mail address. Use the
MailItem.EntryID in that case for getting the corresponding MAPI.Message
object reference.

For saving the attachments you can loop through the MailItem.Attachments
collection and call each object´s SaveAsFile method.

At least accessing an e-mail address is subject to security prompts
since OL2k SP3 (SP2 optional). Please read the infos from Sue:

http://www.outlookcode.com/d/sec.htm
 
Won,

Check out this site. It works perfect for me. You have to create the folders
you want the attachment saved to but the code can append a date/time to the
file name. I get hundreds of emails each day with multiple .jpg and .xls
files attached. The code saves the attached files to the proper folder
depending on whether it is .jpg or .xls or whatever criteria you want to
define.

http://www.fontstuff.com/outlook/oltut01.htm

Wayman
 
Back
Top