Check if email to be processed exists, error Error while processing emails .-2147352567 Array index out of bounds.

  • Thread starter Thread starter Na-gen-dra
  • Start date Start date
N

Na-gen-dra

Guest
Hi

I have 2 task scheduler process running to read the email and execute the same inbox.

There is a delay with start of the two task process, but I process quite some volume of email in that inbox everyday.

Sometimes when I run the second job receive the following error

Error while processing emails .-2147352567 Array index out of bounds.

Is there any other method, than the highlighted below to handle this. This always catches the oI Exception

Dim oItems As Outlook.Items = oInboxFolderLT.Items

iItemsCount = oItems.Count

Do While True
If oItems.Count <= 0 Or
iItemsCount <= 0 Then
Exit Do
End If

' Loop each unread message.
Dim oMsg As Outlook.MailItem = Nothing
Dim oMsgReportItem As Outlook.ReportItem = Nothing


Try
If IsNothing(TypeName(oItems.Item(oItems.Count))) Or_

IsError(TypeName(oItems.Item(oItems.Count))) Then

iItemsCount = iItemsCount - 1
Continue Do
Else
End If

Catch oi As Exception
iItemsCount = iItemsCount - 1
Continue Do
End Try

If FindMatch(TypeName(oItems.Item(iItemsCount)), "ReportItem") Then
oMsgReportItem = oItems.Item(iItemsCount)
oMsgReportItem.Move(oInboxFolderCSR)

'this was added to resolve the server administrator error message
oMsgReportItem.Close(Outlook.OlInspectorClose.olDiscard)
FinalReleaseComObject(oMsgReportItem)
oMsgReportItem = Nothing
Else
oMsg = oItems.Item(iItemsCount)

Do the necessary processing

End if

iItemsCount = iItemsCount - 1

Loop

End Do

Continue reading...
 
Back
Top