• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • Last Modified:

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

0
padillrr
Asked:
padillrr
  • 5
  • 3
2 Solutions
 
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
 
padillrrProject CoordinatorAuthor 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
 
padillrrProject CoordinatorAuthor 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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
 
padillrrProject CoordinatorAuthor 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
 
padillrrProject CoordinatorAuthor 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
 
padillrrProject CoordinatorAuthor Commented:
Come on over! Beers on me! Might be a long way from France but if you make it I'm buying!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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