I'm looking for a LotusScript to manage mails coming from a specific address, say "me@somewhere.com" and forward the message from my notes-mail to a recipient found in the message body after the word "From:".
Ideally I would also like the script to cut all lines in the message between a "£"-sign and the line starting with "From:".
Can this be done?
Software/Hardware used:
ASKED:
February 5, 2009 11:38 AM
UPDATED:
January 16, 2012 7:56 PM
Hello LedLincoln,
I am looking for a similar script; one that can just forward all me messages as if I’m being carbon or blind carbon copied on another address. I don’t know any Lotus Script or Java syntax though. Could you help me out? Thanks.
Boris
Boris,
There are all sorts of caveats to go with such an action as forwarding all of your mail outside of your organization, but the basic method can be as simple as
- go to Rules and click New Rule button
- Set condition as you want (sounds like you want “all documents” from the dropdown) and click the Add button
- Set the actions dropdowns to “send copy to” and “full”, enter the destination email address, and click “Add Action”
- Click OK
Hi Stiletto,
I have that rule setup already but it would be nice to be able to clean up the forwarded messages so the original sender appears in the forward and the fwd headers are removed in the message. I can’t create private agents in notes, I already tried a lotus script.
Hello LedLincoln,
I have made a script (att below) in an agent that forwards mails; working ok except for:
1. All mails are forwarded twice.
2. Mails sent from database appear as “Sent by: <me>”, and not by original sender or database.
Best regards, Trond
Sub Initialize
Dim session As NotesSession
Dim db As New NotesDatabase( “”, “review.nsf” )
Dim Maildoc As notesdocument
Dim coll As NotesDocumentCollection
Dim doc As NotesDocument
Dim a As Integer
Dim itemBody As NotesItem
Set session = New NotesSession
Set db = session.CurrentDatabase
Set coll = db.UnprocessedDocuments
For a=1 To coll.Count
Set doc=coll.GetNthDocument(a)
Set Maildoc = New NotesDocument(db)
Maildoc.Form = “Memo”
Maildoc.Subject = doc.Subject
Set itemBody = doc.GetFirstItem( “Body” )
Call Maildoc.CopyItem( itemBody, “Body” )
Maildoc.From = “<db-mail>”
Maildoc.Principal = “<db-mail>”
Maildoc.SendTo = “recipient1″
Call Maildoc.Send(False)
Maildoc.SendTo = “recipient2″
Call Maildoc.Send(False)
Next
End Sub
To avoid twice send, replace these 4 lines :
Maildoc.SendTo = “recipient1″
Call Maildoc.Send(False)
Maildoc.SendTo = “recipient2″
Call Maildoc.Send(False)
By :
Dim tabSendTo(1) as variant
tabSendTo(0) = “recipient1″
tabSendTo(1) = “recipient2″
Call Maildoc.Send(False, tabSendTo)
Trond,
>1. All mails are forwarded twice.
Well, the code says to send it to “recipient1″ and then it says to send it to “recipient2″, so I would expect it to forward it twice, once to each recipient. Or is that not what you’re experiencing?
>2. Mails sent from database appear as “Sent by: <me>”, and not by original sender or >database.
In the properties box for the agent, go to the second tab and set the “Run on behalf of” field to whatever you want and see if that changes the behavior.
BTW, you should not use GetNthDocument like that; it is incredibly inefficient. Instead, use
Set doc=coll.GetFirstDocument
Do While Not doc Is Nothing
process
doc=coll.GetNextDocument(doc)
Loop
GetNthDocument(x) gets doc #x by starting at the beginning and counting to x. Each time you use it, it starts at the beginning again. So, inside a loop, it starts at the beginning and counts to 1; the next iteration through the loop it starts at the beginning and counts to 2, etc. GetNthDocument is fine if you need to jump to document #37 for some reason (as an example), but other than that, GetFirstDocument/GetNextDocument is probably the better approach.
Thanks BruceWayne and Stiletto;
However, mails still appear twice out from this mailbox; in other words the script is called twice (about one minute apart), on the same event. On the properties box for the agent the Trigger is set to “On event” and “After new mail has arrived”. Hmmm….