Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

before new mail arrives problem

Status
Not open for further replies.

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
 
before new mail has arrived agents are executed on the server, therefor you should not use NotesUI* classes since those are front end only.

Get rid of those UI elements and add:

dim sn as new NotesSession
set doc = sn.DocumentContext



Woonjas
IRC: #notes on EFNet
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top