Forall Loop errors

This agent should be looking at the fields and if there is any domain other then dalinalaw it should mark the document Client if it ONLY contains Dalinalaw than it should be internal. The Forall look is seeing the CC field blank and sending it to Client even though it is being emailed internally. How do I get the loop to bypass any blanks? If the TO field contains someone@dalinalaw.com and someone @gmail.com it should be flied client! I'm stomped and need this today! POINTS UP!
Sub Initialize
	Dim session As NotesSession
	Set session = New NotesSession
	Dim doc As NotesDocument
	Dim SentTo As Variant
	Dim CopiedTo As Variant
	Dim SentBy As Variant
	Dim Recipients As Variant
	Set doc = session.DocumentContext
	'Sets the Company value to the value of the X Field in the MIME Header of the Message
	doc.Company = doc.X_Customer
	
	If doc.Principal(0) = "" Then
		SentBy = doc.from
	Else
		SentBy = doc.Principal
	End If
	SentTo = doc.SendTo
	Copiedto = doc.CopyTo
	Recipients = Arrayappend(SentTo,CopiedTo)
	Recipients = Arrayappend(Recipients,SentBy)
	Forall c In Recipients
		If Instr(c,"dalinalaw") = 0 Then
			mailsort$ = "Client"
			Goto finish
		Else
			mailsort$ = "Internal"
		End If
	End Forall
finish:
	doc.mailsort = mailsort$
	Call doc.Save(True,False)
End Sub

Open in new window

padillrrIT DirectorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sjef BosmanGroupware ConsultantCommented:
Would this help? Replace the lines 22-29 in the code above by:

        mailsort$ = "Internal"
        Forall c In Recipients
                If Instr(c,"dalinalaw") >= 0 Then
                        mailsort$ = "Client"
                        Goto finish
                End If
        End Forall

End of stump? Did you spot the difference? ;-)
0
padillrrIT  DirectorAuthor Commented:
Still marking everything Client if  isend it to dalinalaw it should mark it internal but if I send it to dalinalaw and gmail then it should be client
0
padillrrIT  DirectorAuthor Commented:
when I run it through the debugger I get mailsort Internal until it runs through the Forall then it changes to Client. The loop has (0) "" - this is copyto (CC field) (1) "" - this sendTo (TO field)
(2)dalinalaw - recipients soon as it does the  If Instr(c,"dalinalaw") >= 0 Then  line it changes the c from dalinalaw to "" and it changes the mailsort to Client....

0
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

SysExpertCommented:
Actually, all that i think is missing is a check for a blank string


 Forall c In Recipients
            IF length( c) > 0 then
                If Instr(c,"dalinalaw") = 0 Then
                        mailsort$ = "Client"
                        Goto finish
                Else
                        mailsort$ = "Internal"

                End If
            End If

        End Forall
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sjef BosmanGroupware ConsultantCommented:
Maybe add this line, just before the forall

recipients= fulltrim(recipients)

It will remove all empty strings; they are the problem as SysExpert correctly suggests
0
padillrrIT  DirectorAuthor Commented:
Hey Guys THANK YOU!!! I actually sort of cheated yesterday and just did this
SentTo = doc.SendTo
      Copiedto = doc.CopyTo

But both your responses work so I will split the points! again thanks!!!!!
0
padillrrIT  DirectorAuthor Commented:
You guys ROCK!!! This was driving me nuts!!! We are going to test now and production next week, you saved my job!
0
Sjef BosmanGroupware ConsultantCommented:
What a pity, already solved??  You could have invited us over...

:-))
0
padillrrIT  DirectorAuthor Commented:
Come on over! Beers on me! Might be a long way from France but if you make it I'm buying!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.