lotus notes agent to move incoming mail to folder (based on part of subject)

Posted on 2009-04-07
Last Modified: 2013-12-18
i would like to have an agent that moves an incoming mail to a folder,
but only mails that contain a certain text in the mail body.
other mails will stay in the inbox or will be ove to another folder based on another text.

eg. when the subject contains the text '52.9 ritverzamellijst', the incoming mail should be moved to the same folder '52.9 ritverzamellijst'.
i tried with the attached code, but apparently there's something wrong with the routines that find the text in the body, because the mail stays in the inbox and is not moved.

any expert can fix this code ?
Sub Initialize

	Dim s As New NotesSession

	Dim doc As NotesDocument

	Dim it  As NotesItem

	Dim SPAM As String

	myident = "52.9 ritverzamellijst" ' make this your identifier 

	Set doc = s.documentcontext


	Print "Processing " & doc.subject(0) " from " & doc.From(0)

	Set it = doc.GetFirstItem("Body")

	If it Is Nothing Then

		Print "Exiting"


		Dim stringMyIdent

		stringMyIdent = it.Text

		If Instr( stringMyIdent, myident ) > 0 Then

			Call doc.PutInFolder("52.9 ritverzamellijst", False )

			Print "--> moving to folder  ---"

			Call doc.RemoveFromFolder( "($Inbox)" )

			Print "--> removing from inbox ---"


			Print "--> does not contain 52.9 ritverzamellijst ---"

		End If

	End If

End Sub

Open in new window

Question by:Lieven Embrechts
  • 2
  • 2

Expert Comment

ID: 24086336
Would it not be simpler to use a mail rule?  As this feature is already built into the mail template


Author Comment

by:Lieven Embrechts
ID: 24086376
a mail rule on mail BODY ?  i use notes 7.0.2.

Accepted Solution

daj_uk earned 500 total points
ID: 24086400
yes, see attached screen shot...

Author Comment

by:Lieven Embrechts
ID: 24088176
yup, it's already solved.
i forgot there's something like 'mail rules' next to 'quick rules'.
or i need glasses...
thanks for your quick help !

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Lotus notes email code 6 112
Lotus Domino server 11 62
IBM Lotus notes 9 88
Scan to Email - HP 477 Printer and Lotus Notes 8 70
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now