Copy a large number of MailItem

M

MS

Hi,

I try to copy more than 250 mailitem from my inbox folder to other folder,
"Toto" for example.
When my code attempt to copy the 244 mailitem, it raise an error.
I saw that there is a limit of item opened, which is about 255 but in
reality about 244.

Can somebody help me.

NotAMail

My code (extract from VB application):

Dim olApp As Outlook.Application
Dim objName As NameSpace
Sub Main()
Dim Folder As MAPIFolder, Folder2 As MAPIFolder
Dim objMailItem As Outlook.MailItem
Dim Item As Outlook.MailItem, objTemp As MailItem, objTemp2 As MailItem
Dim i As Long

Set olApp = Outlook.Application
Set objName = olApp.GetNamespace("MAPI")
Set Folder = objName.GetDefaultFolder(olFolderInbox)
Set Folder2 =
objName.GetDefaultFolder(olFolderInbox).Parent.Folders("Toto")

iCount = Folder.Items.Count
For i = 1 To iCount
Set objMailItem = Folder.Items(i)

Set objTemp = objMailItem.Copy
'Set objTemp2 = objTemp.Move(Folder2)

objTemp.Close olDiscard
'objMailItem.Close olDiscard

'Set objTemp2 = Nothing
Set objTemp = Nothing
Set objMailItem = Nothing
Next i

Set objName = Nothing
Set olApp = Nothing
End Sub
 
N

NotAMail

Hi,

One note, the problem seems to occurred only on Outlook 2003. On Outlook XP,
I don't have this problem

NotAMail
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top