A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Slow retrieving items from Outlook



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 18th 07, 02:00 AM posted to microsoft.public.outlook.program_vba
Simon Maystre
external usenet poster
 
Posts: 2
Default Slow retrieving items from Outlook


I am accessing Outlook from Access VBA and whilst the following code works
just fine it seems really slow to just show a list of the mail items that are
in the Inbox are there any suggestions on how this could be speeded up.

Set objFolder = objOutlook.GetNamespace("MAPI").GetDefaultFolder(M ailBox)

With objFolder

lngCount = .Items.Count

If lngCount 0 Then

For Each objOutlookMail In .Items

aryEmails(1, lngCount2) = Nz(objOutlookMail.To, "")
aryEmails(2, lngCount2) = Nz(objOutlookMail.Subject, "")
aryEmails(3, lngCount2) = objOutlookMail.Senton

lngCount2 = lngCount2 + 1

Next

End If

End With

Many thanks


  #2  
Old January 18th 07, 02:19 AM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Slow retrieving items from Outlook

Try using the SetColumns method to retrieve only those properties that you're interested in, e.g.:

.Item.SetColumns ("To, Subject, SentOn")

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Simon Maystre" wrote in message ...

I am accessing Outlook from Access VBA and whilst the following code works
just fine it seems really slow to just show a list of the mail items that are
in the Inbox are there any suggestions on how this could be speeded up.

Set objFolder = objOutlook.GetNamespace("MAPI").GetDefaultFolder(M ailBox)

With objFolder

lngCount = .Items.Count

If lngCount 0 Then

For Each objOutlookMail In .Items

aryEmails(1, lngCount2) = Nz(objOutlookMail.To, "")
aryEmails(2, lngCount2) = Nz(objOutlookMail.Subject, "")
aryEmails(3, lngCount2) = objOutlookMail.Senton

lngCount2 = lngCount2 + 1

Next

End If

End With

Many thanks


  #3  
Old January 18th 07, 11:11 AM posted to microsoft.public.outlook.program_vba
Simon Maystre
external usenet poster
 
Posts: 2
Default Slow retrieving items from Outlook


This did the trick to speed up the load by around 500%! I also changed how I
was referencing the item object slightly and this also improved load time:

Thanks for your help.

Set objFolder = objOutlook.GetNamespace("MAPI").GetDefaultFolder(M ailBox)
Set objOutlookItems = objFolder.Items

With objOutlookItems

.SetColumns ("From, To, SenderName, Subject, SentOn")
lngCount = .Count

If lngCount 0 Then

ReDim aryEmails(3, lngCount - 1)

For lngCount2 = 1 To lngCount

aryEmails(0, lngCount2 - 1) = lngCount2

If MailBox = 5 Then
aryEmails(1, lngCount2 - 1) = Nz(.Item(lngCount2).To, "")
Else
aryEmails(1, lngCount2 - 1) =
Nz(.Item(lngCount2).SenderName, "")
End If

aryEmails(2, lngCount2 - 1) = Nz(.Item(lngCount2).Subject, "")
aryEmails(3, lngCount2 - 1) = .Item(lngCount2).SentOn
Progress lngCount2

Next

End If

End With





"Sue Mosher [MVP-Outlook]" wrote:

Try using the SetColumns method to retrieve only those properties that you're interested in, e.g.:

.Item.SetColumns ("To, Subject, SentOn")

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Simon Maystre" wrote in message ...

I am accessing Outlook from Access VBA and whilst the following code works
just fine it seems really slow to just show a list of the mail items that are
in the Inbox are there any suggestions on how this could be speeded up.

Set objFolder = objOutlook.GetNamespace("MAPI").GetDefaultFolder(M ailBox)

With objFolder

lngCount = .Items.Count

If lngCount 0 Then

For Each objOutlookMail In .Items

aryEmails(1, lngCount2) = Nz(objOutlookMail.To, "")
aryEmails(2, lngCount2) = Nz(objOutlookMail.Subject, "")
aryEmails(3, lngCount2) = objOutlookMail.Senton

lngCount2 = lngCount2 + 1

Next

End If

End With

Many thanks



  #4  
Old December 17th 08, 12:07 PM posted to microsoft.public.outlook.program_vba
VOORSPRONG
external usenet poster
 
Posts: 5
Default Slow retrieving items from Outlook

Sue,

I am looking for a list of the column names to select from to pass with
SetColumns. I can get some columns to work but not all. Would you have the
list for me? Nice when mapped to the functions like SenderName, ReceivedTime
etc.

I also found out that when I pass multiple columnnames in one string with
SetColumns the performance is as poor as without but when I add the selected
columns in individual instructions I do have the performance.

"Sue Mosher [MVP-Outlook]" wrote:

Try using the SetColumns method to retrieve only those properties that you're interested in, e.g.:

.Item.SetColumns ("To, Subject, SentOn")

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Simon Maystre" wrote in message ...

I am accessing Outlook from Access VBA and whilst the following code works
just fine it seems really slow to just show a list of the mail items that are
in the Inbox are there any suggestions on how this could be speeded up.

Set objFolder = objOutlook.GetNamespace("MAPI").GetDefaultFolder(M ailBox)

With objFolder

lngCount = .Items.Count

If lngCount 0 Then

For Each objOutlookMail In .Items

aryEmails(1, lngCount2) = Nz(objOutlookMail.To, "")
aryEmails(2, lngCount2) = Nz(objOutlookMail.Subject, "")
aryEmails(3, lngCount2) = objOutlookMail.Senton

lngCount2 = lngCount2 + 1

Next

End If

End With

Many thanks



  #5  
Old December 17th 08, 03:25 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Slow retrieving items from Outlook

The Outlook VBA Object Browser Help has a list of what properties you cannot
use with SetColumns. Any other properties not listed there can be used with
SetColumns.

Speed with SetColumns and multiple properties is faster than not using
SetColumns. The gain in speed is related to how many columns you ask for and
how large those columns are. If any are larger than can be retrieved using a
MAPITable then retrieving that property will require falling back to an
IStream to retrieve the property, thereby cutting the speed somewhat.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"VOORSPRONG" wrote in message
...
Sue,

I am looking for a list of the column names to select from to pass with
SetColumns. I can get some columns to work but not all. Would you have the
list for me? Nice when mapped to the functions like SenderName,
ReceivedTime
etc.

I also found out that when I pass multiple columnnames in one string with
SetColumns the performance is as poor as without but when I add the
selected
columns in individual instructions I do have the performance.


  #6  
Old December 17th 08, 03:36 PM posted to microsoft.public.outlook.program_vba
VOORSPRONG
external usenet poster
 
Posts: 5
Default Slow retrieving items from Outlook

Ken,

Thanks for the answer.

Two issues; Are the column names identically to the property names and if so
why does SenderName when passed as string not return a value when the
property SenderName is requested. Second; I am not using VBA but a likewise
COM solution (Visual DataFlex). And in VBA when I went to the SetColumns
instruction I only saw that I needed to enter a string.

Regards,
Vincent Oorsprong
Data Access Europe B.V.
Netherlands

"Ken Slovak - [MVP - Outlook]" wrote:

The Outlook VBA Object Browser Help has a list of what properties you cannot
use with SetColumns. Any other properties not listed there can be used with
SetColumns.

Speed with SetColumns and multiple properties is faster than not using
SetColumns. The gain in speed is related to how many columns you ask for and
how large those columns are. If any are larger than can be retrieved using a
MAPITable then retrieving that property will require falling back to an
IStream to retrieve the property, thereby cutting the speed somewhat.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"VOORSPRONG" wrote in message
...
Sue,

I am looking for a list of the column names to select from to pass with
SetColumns. I can get some columns to work but not all. Would you have the
list for me? Nice when mapped to the functions like SenderName,
ReceivedTime
etc.

I also found out that when I pass multiple columnnames in one string with
SetColumns the performance is as poor as without but when I add the
selected
columns in individual instructions I do have the performance.



  #7  
Old December 17th 08, 03:41 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Slow retrieving items from Outlook

Select SetColumns in the Object Browser and click F1. That will open the
Help which has the list of properties you cannot use. All properties use
their object model names. If SenderName is not blank in the items it should
be returned.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"VOORSPRONG" wrote in message
...
Ken,

Thanks for the answer.

Two issues; Are the column names identically to the property names and if
so
why does SenderName when passed as string not return a value when the
property SenderName is requested. Second; I am not using VBA but a
likewise
COM solution (Visual DataFlex). And in VBA when I went to the SetColumns
instruction I only saw that I needed to enter a string.

Regards,
Vincent Oorsprong
Data Access Europe B.V.
Netherlands


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OE6 slow to open and slow to delete wmcmillion Outlook Express 1 October 14th 06 10:56 PM
error retrieving folder.items.count kappe79 Outlook and VBA 3 September 19th 06 02:29 PM
Retrieving information from incomming mail items. Jan G. Thorstensen Outlook and VBA 1 September 18th 06 06:45 AM
creating calendar items VERY slow Al Blake Outlook and VBA 1 February 28th 06 02:13 PM
error 0x80040900 in outlook retrieving mail [email protected] Outlook - General Queries 5 February 15th 06 05:46 PM


All times are GMT +1. The time now is 09:14 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.