View member feedback to this tip.
The following agent makes a copy of a new e-mail, strips it of the CC and BCC fields (to prevent duplicate e-mails to people), inserts the original "Send to" field and then sends the e-mail to any e-mail address specified. This lets a user see who the original sender is. Otherwise, if you're forwarding e-mails to a handheld, the "From" field will always be you.
This new e-mail will also contain a "Header" that gives the user additional information (original recipient, recipients who were copied on the original e-mail, etc.)
This agent must run on the "Before New Mail Arrives" event. Also, set the runtime security level to "2."
Have fun.
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
forwardaddress = "recipient@test.com"
'set to the address that you would like
to forward mail to
Set db = s.currentdatabase
Set doc = s.DocumentContext
Set forward = New NotesDocument(db)
Call doc.CopyAllItems(forward, True)
Set rtitem = forward.GetFirstItem( "Body" )
Dim newtext As String
Set rtnav = rtitem.CreateNavigator
Call rtnav.FindFirstElement(RTELEM_
TYPE_TEXTPARAGRAPH) 'navigation element in
order to place header in front of body text
Dim nn As New NotesName(doc.
GetItemValue("From")(0)) 'determines if this is
an internal message or not
Dim cc As New NotesName(doc.
GetItemValue("CopyTo")(0))
Dim sto As New NotesName(doc.
GetItemValue("SendTo")(0))
'Set up a header that will be attached
to the email which specifies additional
info about the original email
Dim testcopy As String
If doc.GetItemValue("CopyTo")(0) = "" Then
testcopy = "no one."
Else
Forall x In doc.GetItemValue("CopyTo")
If testcopy = Null Then
testcopy = x
Else
testcopy = testcopy + x + ", "
End If
End Forall
End If
If nn.IsHierarchical Then 'if it is then get
their internet address
If nn.Addr821 <> Null Then 'if they
have one then use this as the from
address
Call rtitem.BeginInsert(rtnav)
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText( "Original message
sent to " + sto.Addr821 + " and
copies were sent to " + testcopy)
Call rtitem.AddNewLine( 3 )
Call rtitem.EndInsert
Call forward.RemoveItem("CopyTo")
Call forward.RemoveItem("BlindCopyTo")
Call forward.ReplaceItemValue
("From", nn.Addr821)
Call forward.Save( True, True )
Else
Call rtitem.BeginInsert(rtnav)
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText( "Original message
sent to " + sto.Addr821 + " and
copies were sent to " + testcopy)
Call rtitem.AddNewLine( 3 )
Call rtitem.EndInsert
Call forward.RemoveItem("CopyTo")
Call forward.RemoveItem("BlindCopyTo")
Call forward.ReplaceItemValue("iNetFrom",
nn.Addr821)
Call forward.Save( True, True )
End If 'otherwise if this is an internal
message and the internet address of
that user is not populated, use the agent
signer's return address
Else
Call rtitem.BeginInsert(rtnav)
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText( "Original message
sent to " + doc.GetItemValue
("SendTo")(0) + " and copies were sent to "
+ testcopy)
Call rtitem.AddNewLine( 3 )
Call rtitem.EndInsert
Call forward.RemoveItem("CopyTo")
Call forward.RemoveItem("BlindCopyTo")
Call forward.ReplaceItemValue("iNetFrom",
doc.GetItemValue("From")
(0)) 'otherwise this came in from the internet,
so just use the from address
as the inetfrom
Call forward.Save( True, True )
End If
forward.Send False, forwardaddress
Call forward.RemovePermanently(True)
End Sub
MEMBER FEEDBACK TO THIS TIP
It's a great script, but is there a possibility to forward without an attachment?
Ronald V.
******************************************
I haven't tested this, but this may work with a little modification. This routine checks for embedded objects and then deletes them.
If forward.HasEmbedded Then
Forall x In forward.EmbeddedObjects
call x.remove
End Forall
Else
Steve Pitcher, tip author
Do you have comments on this tip? Let us know.
This tip was submitted to the SearchDomino.com tip exchange by member Steve Pitcher. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.