- Joined
- Feb 2, 2007
- Messages
- 1
- Reaction score
- 0
Hi,
in my code below I create an Outlook.Application object and then iterate through all the messages in the inbox (default folder (6)). However when I get to message number 32 I get an error message.
See below. It says that the array index is out of bounds.
If I try to find out how many items in my inbox using the following statement, it outputs only 34 - yet there are loads of messages in my in box.
objApplication.session.getdefaultfolder(6).items.count
Please, please help. I don't know what's wrong.
Many thanks in advance.
Polly Anna
Code
mobjSession.MAPIOBJECT = mobjSession.MAPIOBJECT
aFolder = CObj(mobjSession.Inbox) ' Choose the folder
objApplication = CreateObject("Outlook.Application")
objApplication.session.getdefaultfolder(6).items(i)
i = 0
For Each Message In aFolder.messages
Try
i = i + 1
' Get the email from the InBox (default folder 6)
objItem = objApplication.session.getdefaultfolder(6).items(i)
If objItem Is Nothing Then Throw New
Net.Mail.SmtpException
("Unable to open the Inbox (default folder 6)")
Catch ex As Exception
strTemp = "Unable to get email item number " & i & " from the Mail box "
objErrorLog = CLogS.GetErrorLogFileInstance
objErrorLog.Add(strTemp & vbCrLf & vbCrLf & ex.ToString)
EndTry
Next
Error Message:-
Unable to get email item number 32 from the Mail box
System.Runtime.InteropServices.COMException (0x80020009): Array index out of bounds.
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
in my code below I create an Outlook.Application object and then iterate through all the messages in the inbox (default folder (6)). However when I get to message number 32 I get an error message.
See below. It says that the array index is out of bounds.
If I try to find out how many items in my inbox using the following statement, it outputs only 34 - yet there are loads of messages in my in box.
objApplication.session.getdefaultfolder(6).items.count
Please, please help. I don't know what's wrong.
Many thanks in advance.
Polly Anna
Code
mobjSession.MAPIOBJECT = mobjSession.MAPIOBJECT
aFolder = CObj(mobjSession.Inbox) ' Choose the folder
objApplication = CreateObject("Outlook.Application")
objApplication.session.getdefaultfolder(6).items(i)
i = 0
For Each Message In aFolder.messages
Try
i = i + 1
' Get the email from the InBox (default folder 6)
objItem = objApplication.session.getdefaultfolder(6).items(i)
If objItem Is Nothing Then Throw New
Net.Mail.SmtpException
("Unable to open the Inbox (default folder 6)")
Catch ex As Exception
strTemp = "Unable to get email item number " & i & " from the Mail box "
objErrorLog = CLogS.GetErrorLogFileInstance
objErrorLog.Add(strTemp & vbCrLf & vbCrLf & ex.ToString)
EndTry
Next
Error Message:-
Unable to get email item number 32 from the Mail box
System.Runtime.InteropServices.COMException (0x80020009): Array index out of bounds.
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)