ExtractFile Fails : GetAttachment Not Finding File

We are experiecing problems extracting some files from a Notes dababase. We have approx 30,000 files attachments to extract and we simply loop through each document extracting all the files. The extract routine is shown below.You should note all the attachments are in $File fields the application is 100% web app. No RTF exists holding the attachments.

We exteract 99% of the files successfully. However about 70 files fail with an “Object Variable Not Set” error. The common factor seems to be some straneg character in the filename e.g.

Name´s_YearSum 2004.pdf

However, if I try and save the attachment from the client it works fine, and I can also open the attachment via the client.

The problem is inputattachment is not set for these types of file. It is as if there has been a mismatch in finding the filename - probably caused by this character?

Any thoughts on how this can be resolved are there alternatives to getting the attachment by name for extract?

				attachlist = Evaluate("@AttachmentNames", doc)



				Forall v In attachlist

					filenamee = v 

					Set inputAttachment = doc.GetAttachment ( fileNamee )

					filePathU = "C:\export\" & fileNamee						

					Call inputAttachment.ExtractFile ( filePathU )



				End Forall

Subject: ExtractFile Fails : GetAttachment Not Finding File

I didn’t understand - Does the code fail at the ExtractFile line? Or does it fail on GetAttachment? Or does it return a blank for the filename when it should be returning

Name´s_YearSum 2004.pdf

If the first, solve it by:

attachlist = Evaluate(“@AttachmentNames”, doc)

detachname = Evaluate({@ReplaceSubstring(@AttachmentNames; “´”:" “; “”:”_")}, doc)

i = 0

Forall v In attachlist

filenamee = v

Set inputAttachment = doc.GetAttachment ( fileNamee )

filePathU = "C:\export" & detachname(i)

i = i + 1

Call inputAttachment.ExtractFile ( filePathU )

End Forall

If anything else, I would make sure that your document creation does not permit those strange characters in the filenames.

Subject: RE: ExtractFile Fails : GetAttachment Not Finding File

It fails at GetAttachment(filenamee)

When I do this on these attachments the object is not set.

Subject: RE: ExtractFile Fails : GetAttachment Not Finding File

Do you have two attachment with the same file name? When you attach a file with a file name that already exist for another attachment in the document the new attachment will have a different name : eg.

first attachment

object.name = “mydoc.doc”

object source = “mydoc.doc”

second attachment

object.name = “ATT743” or something similar

object.source = “mydoc.doc”

the point is that is you delete the first attachment and try to do a GetAttachment on the second it will not find it because of it’s different name. I haven’t found a work around yet… :frowning:

Subject: ExtractFile Fails : GetAttachment Not Finding File

Write a simple code to check for illegal characters and remove/replace them with another character.

Subject: RE: ExtractFile Fails : GetAttachment Not Finding File

How do you do that if you can’t get a handle on the file in the first place though? It is the GetAttachment that fails. The attachment is already named…