Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 192
  • Last Modified:

Challeging Question

Hi,
 I have a requirement where in I have to search documents in Inbox folder of a persons mail file and look for the text category= and based on the value say category=others the agent should put the document in others folder. Can anyone let me know how to do this. I appreciate if one can send a sample code for this

Regards
Rajen
0
Rajen
Asked:
Rajen
1 Solution
 
rfharrisCommented:
Is your search limited to the subject field, the body field, both or unknown?
0
 
RajenAuthor Commented:
Adjusted points to 100
0
 
RajenAuthor Commented:
HI,
Search is subjected to body field only

Regards
Rajen
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
fayebCommented:
If you look in you notes templates there is one called Search in here you can configure the database to search a specific database for a specific word
0
 
ArunkumarCommented:
Hi Rajen !!!

Here is the code.  You may put this in an agent.  And run it from actions menu.

======================================
Dim dc as notesdocumentcollection
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim ss as new notessession
Set db = ss.CurentDatabase
Dim view as notesview
Set view = db.GetView("($Inbox)")

formula = |FIELD Body Contains "category=others" |

Set dc = view.FTSearch(formula , 0 )

If dc.Count = 0 then
msgbox "No documents found for category = others"
Else
Print "Found " & dc.count & " documents for category=others"
Call dc.PutAllInFolder("Others")
End If
=======================================

Good Luck !!!

-Arun

PS:Dont schedule this agent since session class in included in this.
0
 
RajenAuthor Commented:
Hi Arun,
How are u. Hope u remember me.You are from chennai and presently at New York na.Thanks for the code, but the thing is the category might be different ie not only others but also some other vlue say"marketting" etc. In such case how will u extract this value alone in order to put the document in that category

Rajen
0
 
ArunkumarCommented:
Hi Rajen,

You got a terrific memory.  I was in NY till Dec.99 Then moved to MI(michigan)
Working for DaimlerChrysler (a car manufacturing co.)

Coming to your code. Try the following.

======================================
Dim dc as notesdocumentcollection
Dim db As NotesDatabase
Dim ss as new notessession
Dim doc as notesdocument
Set db = ss.CurrentDatabase
Dim view as notesview
Set view = db.GetView("($Inbox)")

txt = InputBox$("What category you want to search ?")

 formula = |FIELD Body Contains category= "| & txt & |"|

j = view.FTSearch(formula , 0 )

For i = 1 To j
  Set doc = view.GetNthDocument( i )
  Call doc.PutInFolder( txt )
Next

If j = 0 then
msgbox "No documents found for selected category"
Else
Print "Found " & j & " documents for specified category"
End If
=======================================
Good Luck !

-Arun

PS1:  This code will create new folders byitself if you dont have that category of search.
PS2: I did not have time to debug this code.  Feel free to contact me if you have any issues.

0
 
ArunkumarCommented:
Oops !  I guess you will have to include one more in declarations

Dim formula as String

-Arun
0
 
RajenAuthor Commented:
Hi Arun,
Let me thankyou for the code. I will test your code also. I have also written a code for this. But here iam replacing newline with #. But if the category value is going to be in the last line it will not replace. Any suggestion. I will try ur code also. Thanks

Rajen


Sub Initialize
     Dim sess As New NotesSession    
     Dim db As notesDatabase
     Dim coll As NotesDocumentCollection
     Dim seldoc As NotesDocument
     Set db = sess.CurrentDatabase
     Set coll = db.UnprocessedDocuments
     For i = 1 To coll.count
          Set newdoc = New NotesDocument(db)          
          Set Seldoc = coll.GetnthDocument(i)
          Dim rtitem As NotesRichTextitem
          Set rtitem = seldoc.GetFirstitem("Body")
          tmp = rtitem.getFormattedText(True,0)
          Newdoc.Fld1=tmp
          Flag="Tmp"          
          Newdoc.Fld2 = Evaluate(| @ReplaceSubstring(Fld1;@NewLine;"#")|, newdoc)
         
DoProcess:                              
          Fromvalue = Evaluate(| @Middle(Fld2;"Category = ";"#") |,Newdoc)
          newfolder$=fromvalue(0)
          Call seldoc.PutInFolder( newfolder$ )
          If Flag(0) = "" Then
               
               Goto Exit_fn
          Else
               Goto DoProcess
          End If
         
Exit_fn:                  
     Next
     Msgbox fromvalue(0)
          'Msgbox Fromvalue(0)
End Sub
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now