RE: Get attachment names using vbscript Karl-Henry Martinsson 26.Feb.13 07:37 PM a Web browser General All ReleasesAll Platforms
One possible reason your code is failing is that you haven't declared doc...
But don't use Evaluate... There are rarely any reason for using it, you can write almost everything in native Lotusscript, and you often can get additional benefits from that.
There are some rare times that Evaluate can be useful, but in general, don't use it.
Take a look at the example code in the online help, look at the ExtractFile method of the NotesEmbeddedObject class.
From the help file:
This script detaches and removes all the file attachments in a document's Body item that are larger than 100,000 bytes. The first file attachment that's found gets detached to c:\reports\newfile1, the second attachment that's found gets detached to c:\reports\newfile2, and so on.
Dim doc As NotesDocument
Dim rtitem As Variant
Dim fileCount As Integer
Const MAX = 100000
fileCount = 0
'...set value of doc...
Set rtitem = doc.GetFirstItem( "Body" )
If ( rtitem.Type = RICHTEXT ) Then
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) _
And ( o.FileSize > MAX ) Then
fileCount = fileCount + 1
Call o.ExtractFile _
( "c:\reports\newfile" & Cstr(fileCount) )
Call o.Remove
Call doc.Save( True, True )
End If
End Forall
End If