Forward Mail Agent

Until R4.6 we didn't have the ability to automatically forward mail. For example, you are leaving to Canada and

you want to check your mail and you cannot RAS in, wouldn't it be nice to tell Notes to forward your mail to your Hotmail until you come back.

This agent forwards messages to the address you provide (along with attachments). The agent should be set to "run when new mail arrives". To overcome the problem of running the agent the agent gets the last five documents from your inbox and checks for a flag called "MYFWD", it forwards only if it is "null". After forwarding it marks the flag so that the next time it does not forward the previously sent mail.

(1)If you are creating this agent, you should have rights to run agents on the server.
(2)The subject shows the first 12 letters of the person who has sent you the mail and then the subject. So, when you receive the forwarded mail, it will be from you and the subject would be:
"From : yourfriend Sub: subject he sent you"

<<<<<<< CODE BEGIN >>>>>>
Sub Initialize
On Error Resume Next
Dim session As New notessession
Dim maildb As notesdatabase
Set maildb = session.currentdatabase
Dim inbox As notesview
Set inbox = maildb.getview("($Inbox)")'get inbox
Call inbox.refresh 'refresh inbox to get newly
'arrived mails after this new mail
Dim newmail As notesdocument
Set newmail = inbox.getlastdocument' get the last document
Dim flag As Integer
flag = 0
For i = 1 To 5 ' check last five documents
If Not(newmail Is Nothing) Then
If newmail.myfwd(0) = "" Then ' if it has not been forwarded
Set doc = New notesdocument(maildb)
doc.form = "Memo"
doc.SendTo = "" 'this should be changed to your e-mail
doc.Subject = "From : " & Left _
(newmail.from(0),12) & "Sub:" & _
newmail.Subject(0)& ""
Forall item In newmail.Items 'check for attachments, if there - copy to new mail
If ( = "$FILE") then
Dim ritem As NotesRichTextItem
Set ritem = New NotesRichTextItem _
(doc, "Body")
Dim rtext As String
Dim oritem As NotesRichTextItem
Set oritem = newmail.GetFirstItem("body")
Call ritem.AppendRTItem( oritem )
rtext = oritem.getformattedText(False, 0)
Call ritem.AppendText( rtext )
flag = 1
End If
If flag <> 1 Then
doc.body = newmail.body 'if no attachment then just copy the text
flag = 0
End If
End Forall
Call doc.send(False)'forward/send the mail
newmail.myfwd = "yes" 'flag the forwarded mail
Call,True) ' save after flag
End If
End If
Set newmail = inbox.getprevdocument(newmail)
End Sub
<<<<<<<CODE END >>>>>>>>

This was first published in November 2000

Dig deeper on Domino Resources - Part 2



Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:



  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...