Saving and Renaming Attachments

G

Guest

I receive files that are attachments, usually .xls or .txt files. I would
like to write code that selects the attachment and saves it to the
appropriate location.

My files are usually named randomName.txt as I don't know what the name of
the file will be.

The step I go through now is to right click and then select save as and then
name the file.


One step further- Sometimes I receive two files. They will have common names
but might place the date or other variable in the name; how could I select
this through vba(the appropriate file and then save it)?

Example: I receive two attachments that are - file0725.txt and another that
is named businessTooMuchInformation.txt. I would like to be able to select
each file in turn and save the them with the new name of: file.txt and
business.txt

How would I do this?
 
M

Michael Bauer

Am Thu, 27 Jul 2006 07:42:02 -0700 schrieb csergent:

The MailItem has an Attachment collection. You could loop through that and
save each object with SaveAsFile. That object also has a FileName property,
which you can read and use for the SaveAsFile method.

An example is availabe in the VBA help.
 
G

Guest

Michael,
This has worked very well. I click on the link that I receive in my e-mail
so that I can mark this as helpful but get sent to: "The Page You Have
Requested is Not Available." And then I click on the FAQ's page, but I wasn't
sure what to select since the problem was with the support page.

I hope that this message is noticed, because I do want give credit to the
users that help me out on this site.

Thanks again.
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top