Horrid
Programmer
- May 20, 1999
- 373
The following script detaches the attachments and places them into a folder. I had it working at one point if you opened the message and it currently works on the first email rather than a selected email. I need it to work on an email that triggers the "before new mail arrives" condition. It seems that it does not correctly set the document object. Can anyone point out what I am doing wrong? I have tried with just dim doc as notesdocument, same problem, it seems the document object isn't correclty set to the email I am trying to deal with.
Its a bit of a hack job at the moment hence the somewhat odd code layout.
Sub Initialize
Dim rtitem As Variant
Dim fileCount As Integer
Const MAX = 1000
fileCount = 0
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
'...set value of doc...
Set rtitem = doc.GetFirstItem("Body"
Print "detach attempt"
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) And ( o.FileSize > MAX ) Then
fileCount = fileCount + 1
Call o.ExtractFile ( "\\networklocation\remoteshare\" & o.source )
Call o.Remove
Call doc.Save( True, True )
End If
End Forall
Print "detach finished"
End Sub
Its a bit of a hack job at the moment hence the somewhat odd code layout.
Sub Initialize
Dim rtitem As Variant
Dim fileCount As Integer
Const MAX = 1000
fileCount = 0
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
'...set value of doc...
Set rtitem = doc.GetFirstItem("Body"
Print "detach attempt"
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) And ( o.FileSize > MAX ) Then
fileCount = fileCount + 1
Call o.ExtractFile ( "\\networklocation\remoteshare\" & o.source )
Call o.Remove
Call doc.Save( True, True )
End If
End Forall
Print "detach finished"
End Sub