Link to home
Start Free TrialLog in
Avatar of PinkDolphin
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
Avatar of Jean Marie Geeraerts
Jean Marie Geeraerts
Flag of Belgium image

You code should be :
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
ASKER CERTIFIED SOLUTION
Avatar of HemanthaKumar
HemanthaKumar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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