Thanks:  0
Likes:  0
Dislikes:  0

1. ## Problem cosist

Hi,
I still have the same problem
this is my cose:
End If
For i=1 to MyFolder4.Items.Count
If myItems(i).Subject = "anything" Then
.....
End if
'Delete message with subject not equal to "[Error]" message
If myItems(i).Subject &lt;&gt; "[Error]" Then
myItems(i).delete
end if
myItems.GetNext
Next

the problem is that each time i run the script i get an
error message "array is out of bound"
thanks

2. ## Re: Problem cosist

Same suggestion as I just made for another interation problem:

http://www.sqaforums.com/showflat.ph...;Number=517718

3. ## Re: Problem cosist

Sorry your solution is not working the loop must start from 1 otherwise it wont run at all
Thanks

4. ## Re: Problem cosist

I'm assuming your MyFolder4.Items.Count value is 5 but your myItems array is out of bounds on myItems(5).Subject as the array needs to be referenced as 0 thru 4.

If so try:

For i=0 to MyFolder4.Items.Count - 1
If myItems(i).Subject = "anything" Then
.....
End if
'Delete message with subject not equal to "[Error]" message
If myItems(i).Subject &lt;&gt; "[Error]" Then
myItems(i).delete
end if
myItems.GetNext
Next

Mark Smith.

5. ## Re: Problem cosist

Hi,
it doesn't solve the problem friend.
i really don't know what can be the problem
does any one can solve this issue????
Thanks

6. ## Re: Problem cosist

The issue is with modification of loop within the loop itself

<font class="small">Code:</font><hr /><pre>
For i=1 to MyFolder4.Items.Count
If i &gt; MyFolder4.Items.Count Then Exit For
If myItems(i).Subject = "anything" Then
.....
End if

'Delete message with subject not equal to "[Error]" message
If myItems(i).Subject &lt;&gt; "[Error]" Then
myItems(i).delete
i = i - 1 'Because we deleted one item next item would shift to left
end if
myItems.GetNext
Next
</pre><hr />

7. ## Re: Problem cosist

Well,
yuor solution is almost working but the moment it deleted an emqail and decrease i with 1 and goes back to the for loop and increase it again and that it can't fing the email it just deleted and stops with an error

8. ## Re: Problem cosist

Not a problem

<font class="small">Code:</font><hr /><pre>
Dim oDelete
Dim z: z = 1
Set oDelete = CreateObject("Scripting.Dictionary")
For i=1 to MyFolder4.Items.Count
If i &gt; MyFolder4.Items.Count Then Exit For
If myItems(i).Subject = "anything" Then
.....
End if

'Delete message with subject not equal to "[Error]" message
If myItems(i).Subject &lt;&gt; "[Error]" Then
Set oDelete(z) = myItems(i)
z = z + 1
end if
myItems.GetNext
Next

For i = 1 to oDelete.Count
oDelete(i).Delete
Next
</pre><hr />

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.