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 = "yourname@yourdomain.com" '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 (item.name = "$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 newmail.save(False,True) ' save after flag
End If
End If
Set newmail = inbox.getprevdocument(newmail)
End Sub
<<<<<<<CODE END >>>>>>>>

This was first published in November 2000

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.