Lotus Notes FAQ Visit Our Sponsor!

Can you forward a copy of a user's mail and keep it in their mailbox?

You can use R6 Mail Rules in their mailbox, but the problem is that all the forwarded mail looks like it comes from you.

As an alternative, you can use this Before New Mail Arrives agent. However, it cannot include the Cc list directly; it has to be part of the mail message so a duplicate copy of the forwarded mail doesn't get sent to the original Cc list. This nice thing about this agent is that it retains the original "From" address so the user can reply to the sender directly.

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
' **** set to the address that you would like to forward mail to ****
forwardaddress = "test@test.com"
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
'navigation element in order to place header in front of body text
Set rtnav = rtitem.CreateNavigator
Call rtnav.FindFirstElement(RTELEM_TYPE_TEXTPARAGRAPH)
'determines if this is an internal message or not
Dim nn As New NotesName(doc.GetItemValue("From")(0))
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 since we include the Cc list directly
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
' otherwise if this is an internal message and the internet address of ' that user is not populated, use the agent signer's return 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("iNetFrom", nn.Addr821)
Call forward.Save( True, True )
End If
Else
'otherwise this came in from the internet, so just use the from address as the inetfrom
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))
Call forward.Save( True, True )
End If
forward.Send False, forwardaddress
Call forward.RemovePermanently(True) End Sub


Applies to Notes Versions: 5 6 6.5 7
Last Modified: April 12, 2005