PinkDolphin
asked on
check attachment name
Hi,
the following codes check the filename of attachments.
It always returns me the first filename. The no. of times it is printed tallies with the no. of attachments. However, if I close the current document, re-open it and run the same codes, it returns me the correct filenames.
It works the same if I save the current doc instead of creating a temporary document.
Is this got to do with Notes itself?
Thanks.
'Check filename attached
Set tmpdoc = New notesdocument(db)
Call doc.Copyallitems(tmpdoc, True)
tmpdoc.Form = "TEMP"
Call tmpdoc.save(True, True) 'create temporary doc to check attachments
If Not (tmpdoc Is Nothing) Then
Forall attmt In tmpdoc.Items
If attmt.Name = "$FILE" Then
Print attmt.values(0)
End If
End Forall
End If
the following codes check the filename of attachments.
It always returns me the first filename. The no. of times it is printed tallies with the no. of attachments. However, if I close the current document, re-open it and run the same codes, it returns me the correct filenames.
It works the same if I save the current doc instead of creating a temporary document.
Is this got to do with Notes itself?
Thanks.
'Check filename attached
Set tmpdoc = New notesdocument(db)
Call doc.Copyallitems(tmpdoc, True)
tmpdoc.Form = "TEMP"
Call tmpdoc.save(True, True) 'create temporary doc to check attachments
If Not (tmpdoc Is Nothing) Then
Forall attmt In tmpdoc.Items
If attmt.Name = "$FILE" Then
Print attmt.values(0)
End If
End Forall
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ah yes, I thought he was referring to an existing document, not a newly created one.
My bad, thanks for the correction Hemanth.
So for a complete code this would be :
'First save the document to actually create the attachments
call doc.Save(True,False)
'Now walk through all attachments to get the names
Forall attmt in doc.EmbeddedObjects
Print attmt.name
End Forall
My bad, thanks for the correction Hemanth.
So for a complete code this would be :
'First save the document to actually create the attachments
call doc.Save(True,False)
'Now walk through all attachments to get the names
Forall attmt in doc.EmbeddedObjects
Print attmt.name
End Forall
Forall attmt in doc.EmbeddedObjects
Print attmt.name
End Forall
This code will run through all attachments in the current document (I suppose doc refers to the original document in your code) and print theire respective names.
Regards,
Jean Marie