lotus agent “ingore” mails with attachments when event triggered
10 pts.
0
Q:
lotus agent "ingore" mails with attachments when event triggered
OK, I have put together an agent to forward mail, it is supposed to remove any large attachment and include some data.

When run manually in the UI it works perfect, however when set to run "Before mail arrives" it only forwards mail without any attachments...

The code:

Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim forward As NotesDocument
Dim forwardaddress As String
Dim rtitem As NotesRichTextItem
Dim rtnav As NotesRichTextNavigator
Dim atta As String
Dim remo As String

' **** set to the address that you would like to forward mail to, maxsize of attachements ****
forwardaddress = "mine@outside.com"
Const MaxSize = 3000000

Set db = s.currentdatabase
Set doc = s.DocumentContext

Set forward = New NotesDocument(db)
Call doc.CopyAllItems(forward, True)
Set rtitem = forward.GetFirstItem( "Body" )

'determine if any attachment exist, remove them if they are to big

atta = "no attachments included"
remo = ""
If Not Isempty (rtitem.EmbeddedObjects) Then
atta = ""
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) And (o.FileSize > MaxSize) Then
remo = "removed attachment: "
atta = atta + o.source + ", "
Call o.Remove
Call forward.Save(True,True)
End If
End Forall
End If

'navigation element in order to place header in front of body text
Set rtnav = rtitem.CreateNavigator
Call rtnav.FindFirstElement(RTELEM_TYPE_TEXTPARAGRAPH)


'print recipients into the new mail heading

Call rtitem.BeginInsert(rtnav)
'all kinds of data inserted here as texts
Call rtitem.EndInsert

Call forward.RemoveItem("CopyTo")
Call forward.RemoveItem("BlindCopyTo")


forward.Send False, forwardaddress
Call forward.RemovePermanently(True)
End Sub

Can someone please solve this?

I have also tried to set the agent to run "after new mail has arrived" on all new mail messages but then nothing gets forwarded...
ASKED: Mar 12 2009  3:42 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
1155 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
Complete shot in the dark here. Given your use of constants like EMBED_ATTACHMENT and RTELEM_TYPE_TEXTPARAGRAPH, is it possible they aren't resolving properly on the server, but are working okay on the client? What happens if you replace them with their actual values?

Also, have you checked security settings to ensure that your code can run on the server?
Last Answered: Mar 13 2009  1:15 PM GMT by Stiletto   1155 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Brooklynegg   2685 pts.  |   Mar 13 2009  1:35PM GMT

Also, is an error appearing in the log? If there are errors and no error handling in the agent, they should write to the server log.

 
0