PC Review


Reply
Thread Tools Rate Thread

Copy a large number of MailItem

 
 
NotAMail
Guest
Posts: n/a
 
      18th Aug 2005
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.

The problem occurs only on Outlook 2003. Not on Outlook 200 and XP(2002).

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



 
Reply With Quote
 
 
 
 
Michael Bauer
Guest
Posts: n/a
 
      19th Aug 2005
Am Thu, 18 Aug 2005 14:02:42 +0200 schrieb NotAMail:

Hi,

please try this:

Dim obj as Object

For Each obj in Folder
If TypeOf obj is Outlook.MailItem Then
Set objMailItem=obj
Set objTemp=objMailItem.Copy
Set objTemp=objTemp.Move Folder2
Set objTemp=Nothing
Set objMailItem=Nothing
Endif
Next

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook

> 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.
>
> The problem occurs only on Outlook 2003. Not on Outlook 200 and

XP(2002).
>
> 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

 
Reply With Quote
 
NotAMail
Guest
Posts: n/a
 
      22nd Aug 2005
Hello Michael,

I have try your code, and the same error appeared.

NotAMail


"Michael Bauer" <(E-Mail Removed)> wrote in message
news:3vdcbf6rph4p.fwzo5upyaq9o$.(E-Mail Removed)...
> Am Thu, 18 Aug 2005 14:02:42 +0200 schrieb NotAMail:
>
> Hi,
>
> please try this:
>
> Dim obj as Object
>
> For Each obj in Folder
> If TypeOf obj is Outlook.MailItem Then
> Set objMailItem=obj
> Set objTemp=objMailItem.Copy
> Set objTemp=objTemp.Move Folder2
> Set objTemp=Nothing
> Set objMailItem=Nothing
> Endif
> Next
>
> --
> Viele Gruesse / Best regards
> Michael Bauer - MVP Outlook
>
> > 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.
> >
> > The problem occurs only on Outlook 2003. Not on Outlook 200 and

> XP(2002).
> >
> > 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



 
Reply With Quote
 
Michael Bauer
Guest
Posts: n/a
 
      22nd Aug 2005
Am Mon, 22 Aug 2005 15:00:59 +0200 schrieb NotAMail:

You could use CDO instead of the Outlook object modell, which hasnīt a
memory leak. Maybe you need to install CDO first because itīs an
optional component (available on your Office CD).

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook

> Hello Michael,
>
> I have try your code, and the same error appeared.
>
> NotAMail
>
>
> "Michael Bauer" <(E-Mail Removed)> wrote in message
> news:3vdcbf6rph4p.fwzo5upyaq9o$.(E-Mail Removed)...
>> Am Thu, 18 Aug 2005 14:02:42 +0200 schrieb NotAMail:
>>
>> Hi,
>>
>> please try this:
>>
>> Dim obj as Object
>>
>> For Each obj in Folder
>> If TypeOf obj is Outlook.MailItem Then
>> Set objMailItem=obj
>> Set objTemp=objMailItem.Copy
>> Set objTemp=objTemp.Move Folder2
>> Set objTemp=Nothing
>> Set objMailItem=Nothing
>> Endif
>> Next
>>
>> --
>> Viele Gruesse / Best regards
>> Michael Bauer - MVP Outlook
>>
>>> 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.
>>>
>>> The problem occurs only on Outlook 2003. Not on Outlook 200 and

>> XP(2002).
>>>
>>> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy a large number of MailItem MS Microsoft Outlook 1 18th Aug 2005 11:05 AM
How to delete and copy large number of messages in a PF Victor Matei Microsoft Outlook Third-Party Utilities 1 14th Oct 2004 07:02 AM
How to delete and copy large number of messages in a PF Victor Matei Microsoft Outlook Program Addins 0 28th Sep 2004 11:03 PM
copy large number of files fails Paul Pedersen Windows XP General 2 23rd Apr 2004 03:36 PM
File copy slow when large number of files Ollie G Microsoft Windows 2000 File System 3 11th Jul 2003 12:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:24 AM.