Subject: RE: Repost - sorry. FindFirstString
Thanks Andre… THANK YOU THANK YOU THANK YOU. I really appreciate it.
I specifically chose text that was in the body of the message from a document I selected - I will post my code below but it ain’t pretty.
I was wondering if it made more sense to use getunformattedtext and instr to search for text? What would be the limitations?
I want to check the whole body for different phrases that I will keep in another doc “job search” “resume” etc.
I am leaving for a trip on sunday and wont return until thanksgiving - but I will be checking here for your (always insightful and educational) responses.
I’m checking is the sender/recipient is a member of one group or another. If one group sends to another, I want to keep it, if one group has email with questionable content, I’d also like to keep it.
Sorry for this very crude, not so quick code, it’s not very good - I have to not check the same name so many times, etc, once a match is found I should move on etc, and I’ll work on that when I return but here’s what I have so far
Sub Initialize
Dim session As New NotesSession
Dim dbNAB As NotesDatabase
Set dbNAB = session.AddressBooks(1)
Print "number of nabs is" + Cstr(Ubound(session.AddressBooks))
Print "title is " + dbNAB.Title
Print "Filepath is " + dbNAB.FilePath
Print "Server is " + dbNaB.Server
Dim arr3
Dim strGroupName As String
Dim lx As String
Dim ws As New notesuiworkspace
Dim depts(0 To 1) As String
’ create an array of names based on groups members (GetGroupMembers)
depts(0)="Management"
depts(1)="_Systems"
Dim deptNAB As String
Dim inetAddress As String
Dim colValue As Variant
Dim adress As String
Dim sFormula As String
Dim eMailAliases As Variant
Dim viewNAB As NotesView
Dim vcNAB As NotesViewEntryCollection
Dim entryNAB As NotesViewEntry
Dim docNAB As notesdocument
Dim systemsList List As String
Dim mgmtList List As String
Dim targetList List As String
Dim archiveFlag As Boolean
Dim xnamearr As Variant
Dim sysxnamearr As Variant
Dim mgmtxnamearr As Variant
Dim TargetSysX As Variant
Dim TargetMgmtX As Variant
Call dbNAB.Open("","")
Set viewNAB=dbNAB.GetView("$Users")
Set vcNAB = viewNAB.AllEntries
Set entryNAB = vcNAB.GetFirstEntry
’ build group lists
While Not entryNAB Is Nothing
Set docNAB=entryNAB.Document
’ Evaluate(view.columns(x-1).Formula,entry.document)
deptNAB=docNAB.Department(0)
Select Case deptNAB
Case "IT Department"
sysxnamearr=Evaluate(viewNAB.columns(0).Formula,docNAB)
Forall sysX In sysxnamearr
systemsList(sysX)= Lcase(sysX)
End Forall
Case "Management"
mgmtxnamearr=Evaluate(viewNAB.columns(0).Formula,docNAB)
Forall mgmtX In mgmtxnamearr
mgmtList(mgmtX)=Lcase(mgmtX)
End Forall
End Select
Set entryNAB=vcNAB.GetNextEntry(entryNAB)
Wend
Stop
’ +++++++++++++++++++++++++++++++++++
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim retvTargetNames As Variant
Dim note As NotesDocument
Dim result As Variant
Dim resultArr As Variant
Dim item As NotesItem
Dim nameUser As NotesName
Dim sName As String
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set note = dc.GetFirstDocument
Dim fieldnames(0 To 6) As String
fieldnames(0)="From"
fieldnames(1)="SMTPOriginator"
fieldnames(2)="Principal"
fieldnames(3)="SendTo"
fieldnames(4)="CopyTo"
fieldnames(5)="BlindCopyTo"
fieldnames(6)="Recipients"
Dim mgmtflag As Boolean
Dim sysflag As Boolean
Dim pos As Integer
Dim pos2 As Integer
Dim sUser As String
Dim isx400 As Integer
While Not note Is Nothing
mgmtflag=0
sysflag=0
’ check from first
Forall fname In fieldnames
If note.HasItem(fname) Then
’ get individual names
Set item = note.GetFirstItem(fname)
Forall sUsername In item.Values
’ loop and process each name
’ remove extra quotes from crappy address
sUser=StringReplaceSubstring(Cstr(sUserName),|"|,"")
sUser=StringReplaceSubstring(Cstr(sUser),|'|,"")
Stop
retvTargetNames=GetGroupMembers(sUser,dbNAB)
If retvTargetNames(0)<> "" Then
Forall retvs In retvTargetNames
lx=Lcase(retvs)
Call AddToArray(TargetNames, lx)
If Iselement(systemslist(lx))= True Then
sysflag=True
End If
If Iselement(mgmtlist(lx))= True Then
mgmt=True
End If
End Forall
Else
Set nameUser = New NotesName(sUser)
If nameUser.Addr821 <>"" Then
lx=Lcase(nameUser.Addr821)
Call AddToArray(TargetNames, lx)
If Iselement(systemslist(lx))= True Then
sysflag=True
End If
If Iselement(mgmtlist(lx))= True Then
mgmt=True
End If
End If
If nameUser.Common<>"" Then
lx=Lcase(nameUser.Common)
Call AddToArray(TargetNames, lx)
If Iselement(systemslist(lx))= True Then
sysflag=True
End If
If Iselement(mgmtlist(lx))= True Then
mgmt=True
End If
End If
If nameUser.Canonical <>"" Then
lx=Lcase(nameUser.Canonical)
Call AddToArray(TargetNames, lx)
If Iselement(systemslist(lx))= True Then
sysflag=True
End If
If Iselement(mgmtlist(lx))= True Then
mgmt=True
End If
End If
If nameUser.Abbreviated<>"" Then
lx=Lcase(nameUser.Abbreviated)
Call AddToArray(TargetNames, lx)
If Iselement(systemslist(lx))= True Then
sysflag=True
End If
If Iselement(mgmtlist(lx))= True Then
mgmt=True
End If
End If
End If
’ +++++++++++++++++++++++++++++++++++++++++++++++
nextname:
End Forall
End If
End Forall
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
’ archiveFlag=False
’ Dim soundexsearch As String
’ resultArr = Arrayunique( Fulltrim(TargetNames),5)
Stop
If sysflag=True And mgmtflag=True Then
’ communications bn systems and mgmt
Call note.PutInFolder( "X_MGMT_SYSTEMS",True )
Elseif sysflag=True And mgmtflag=False Then
’ check content for job search, illicit contect, etc from systems personnel
Set body = note.GetFirstItem("Body")
Set rtnav = body.CreateNavigator
Set rtrange = body.CreateRange
'profile document value
searchString$="job"
If rtnav.FindFirstString(searchString$,1)=True Then
'keep email
Msgbox "keep email"
Call note.PutInFolder( "X_String_SYSTEMS",True )
Else
'remove email
Msgbox "remove mail"
Call note.PutInFolder( "X_DEL_SYSTEMS",True )
End If
Else
’ email not systems or mgmt no need to keep or review
Call note.PutInFolder( "X_NOT_SYSTEMS",True )
End If
Call note.RemoveFromFolder("($InBox)")
Erase retvTargetNames
Set note = dc.GetNextDocument(note)
Wend
Stop
End Sub