error - cannot save the attachment

V

Venkat

Hi,

When I tried to save the attachments of a mail item, using
the following code snippet,

strTempFolderPath = "C:\temp\"
For intLoop = 1 To objAttachments.Count
objAttachments.Item(intLoop).SaveAsFile strTempFolderPath
& objAttachments.Item(intLoop).FileName
Next

I got an error message "Cannot save the attachment. The
file name is in use by Outlook for a temporary file.
Rename the item, and then try again."

What does the error message mean? What is the cause and
resolution for this error? Please clarify as soon as
possible.

Venkat.
 
J

James Winton

You might try outputing to a different directory.
Version of OL, Dev Environment and windows platform would help.

I put your code into a vb.net, OL2002 and windows 2k,

I was able to reproduce your error "Additional information: Cannot save the
attachment. This file name is in use by Outlook for a temporary file. Rename
the item, and then try again."

when you open an e-mail with an attachement, the attachement is stored in a
temp folder on the local hard drive. My attachments are tucked way under my
doc and settings folder. Yours appear to be going to the C:\temp\ folder.
so, when you try to save it there, you are blocked by outlook, since outlook
has already placed a copy of it there. If you output to a different
directory, you will probably be ok.

What OS are you on? I'm going to guess NOT XP or 2000 or NT. Just seeing if
I have a clue.
 
J

James Winton

You may also want to loop through the attachments collection, rather than
using a for loop counter.

dim objAttchments as attachments
dim objAttchment as attachment

for each objAttchments in objAttchments
'executing code
next
 
V

Venkat

Outlook Version : 2000
Dev Environment : Visual Basic 6.0, MS Office 9.0 Object
Library, MS Outlook 9.0 Object Library
Windows Platform : Windows NT Workstation

But I run the application in Windows 2000 Professional
machine having outlook 2000.

In my application, I have used Environ$("Temp") for saving
the attachments of a mail item. Not hardcoded "C:\Temp\".
Expecting a reply.

Thanks,
Venkat.
 
J

James Winton

The issue is still the same then, and it makes more sense.

Check the value of Environ$("Temp") before you do save as on an attachement.
Go to that path and you will see the File is already there, placed there by
outlook when you opened the message.

You will need to save the file somewhere other than the Temp var path.
 

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