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

folder.Items.count doesnt work with Outlook2003



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 26th 07, 12:36 PM posted to microsoft.public.outlook.program_vba
RSunday
external usenet poster
 
Posts: 7
Default folder.Items.count doesnt work with Outlook2003

I have some VBA code in Access that reads mails. It works in Outlook 2000 -
but now with Outlook 2003 it doesn't any more.

I loop through the contents of a mail folder based on the value
"folder.Items.count" where "folder" is an Outlook.MAPIFolder - but now it
shows count = 0

Is there something I should change in my objects or what...

Alternatively some sample code showing how to get the mail objects from a
folder would be relevant.

Thanks
Ads
  #2  
Old April 26th 07, 04:00 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default folder.Items.count doesnt work with Outlook2003

Show the code you're using. All of my code that iterates folders still works
identically in Outlook 2003 and even Outlook 2007.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"RSunday" wrote in message
...
I have some VBA code in Access that reads mails. It works in Outlook 2000 -
but now with Outlook 2003 it doesn't any more.

I loop through the contents of a mail folder based on the value
"folder.Items.count" where "folder" is an Outlook.MAPIFolder - but now it
shows count = 0

Is there something I should change in my objects or what...

Alternatively some sample code showing how to get the mail objects from a
folder would be relevant.

Thanks


  #3  
Old April 27th 07, 12:14 PM posted to microsoft.public.outlook.program_vba
RSunday
external usenet poster
 
Posts: 7
Default folder.Items.count doesnt work with Outlook2003

This is my code:

Public Sub fill_mail_table(folder As Outlook.MAPIFolder, no As Integer)
Dim mail As Savemaildata
Dim dbs As Database
Dim rst As Recordset
Dim to_list As String
Dim i As Integer

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("folder mails")

' get all mails in the folder
mail = Get_first_Mail(folder)
Do While Not OutlookEOF()
With rst
.AddNew
![mail index] = glngCurrentItem
!MessageID = mail.MessageID
!Subject = mail.Subject
!body = mail.body
!from = mail.from
!received = mail.received
!created = mail.CreateDate
!folder = no
to_list = ""
i = 0
While i UBound(mail.Recipients)
i = i + 1
to_list = to_list & mail.Recipients(i) & ";"
Wend
!to = left(to_list, 255)
.update
End With
mail = Get_next_Mail(folder)
Loop

End Sub


the following procedures are called - and in the Get_first_Mail, the code
stops as
folder.Items.count shows 0.


Public Function Get_first_Mail(folder As Outlook.MAPIFolder) As Savemaildata
Dim tMailItem As Savemaildata
'Dim objitem As Outlook.MailItem 'changed 2001-03-29
Dim objitem As Object

glngCurrentItem = 0
glngMaxItems = 0

glngMaxItems = folder.Items.count
If glngMaxItems 0 Then
glngCurrentItem = 1
Set objitem = folder.Items.Item(glngCurrentItem)
tMailItem = OutlookParseItem(objitem, gstrSaveFolder)
Get_first_Mail = tMailItem
End If
End Function


Public Function Get_next_Mail(folder As Outlook.MAPIFolder) As ABCmaildata
Dim tMailItem As Savemaildata
'Dim objitem As Outlook.MailItem 'changed 2001-03-29
Dim objitem As Object

glngCurrentItem = glngCurrentItem + 1

If Not OutlookEOF Then
Set objitem = folder.Items.Item(glngCurrentItem)
tMailItem = OutlookParseItem(objitem, gstrSaveFolder)
Get_next_Mail = tMailItem
End If
End Function


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

Show the code you're using. All of my code that iterates folders still works
identically in Outlook 2003 and even Outlook 2007.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"RSunday" wrote in message
...
I have some VBA code in Access that reads mails. It works in Outlook 2000 -
but now with Outlook 2003 it doesn't any more.

I loop through the contents of a mail folder based on the value
"folder.Items.count" where "folder" is an Outlook.MAPIFolder - but now it
shows count = 0

Is there something I should change in my objects or what...

Alternatively some sample code showing how to get the mail objects from a
folder would be relevant.

Thanks



  #4  
Old April 27th 07, 03:48 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default folder.Items.count doesnt work with Outlook2003

The code looks OK to me offhand. Have you stepped it and made sure that the
folder that's passed is the correct one and made sure everything else is OK
up to folder.items.count returning 0?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"RSunday" wrote in message
...
This is my code:

Public Sub fill_mail_table(folder As Outlook.MAPIFolder, no As Integer)
Dim mail As Savemaildata
Dim dbs As Database
Dim rst As Recordset
Dim to_list As String
Dim i As Integer

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("folder mails")

' get all mails in the folder
mail = Get_first_Mail(folder)
Do While Not OutlookEOF()
With rst
.AddNew
![mail index] = glngCurrentItem
!MessageID = mail.MessageID
!Subject = mail.Subject
!body = mail.body
!from = mail.from
!received = mail.received
!created = mail.CreateDate
!folder = no
to_list = ""
i = 0
While i UBound(mail.Recipients)
i = i + 1
to_list = to_list & mail.Recipients(i) & ";"
Wend
!to = left(to_list, 255)
.update
End With
mail = Get_next_Mail(folder)
Loop

End Sub


the following procedures are called - and in the Get_first_Mail, the code
stops as
folder.Items.count shows 0.


Public Function Get_first_Mail(folder As Outlook.MAPIFolder) As
Savemaildata
Dim tMailItem As Savemaildata
'Dim objitem As Outlook.MailItem 'changed 2001-03-29
Dim objitem As Object

glngCurrentItem = 0
glngMaxItems = 0

glngMaxItems = folder.Items.count
If glngMaxItems 0 Then
glngCurrentItem = 1
Set objitem = folder.Items.Item(glngCurrentItem)
tMailItem = OutlookParseItem(objitem, gstrSaveFolder)
Get_first_Mail = tMailItem
End If
End Function


Public Function Get_next_Mail(folder As Outlook.MAPIFolder) As ABCmaildata
Dim tMailItem As Savemaildata
'Dim objitem As Outlook.MailItem 'changed 2001-03-29
Dim objitem As Object

glngCurrentItem = glngCurrentItem + 1

If Not OutlookEOF Then
Set objitem = folder.Items.Item(glngCurrentItem)
tMailItem = OutlookParseItem(objitem, gstrSaveFolder)
Get_next_Mail = tMailItem
End If
End Function


 




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
Outlook 2003 find feature doesnt work [email protected] Outlook - General Queries 0 January 22nd 07 10:24 PM
ItemAdd in Deleted Items event doesnt fire after a while [email protected] Add-ins for Outlook 11 January 8th 07 09:27 AM
ItemAdd in Deleted Items event doesnt fire after a while SHUperb Outlook - Calandaring 0 January 5th 07 08:41 AM
error retrieving folder.items.count kappe79 Outlook and VBA 3 September 19th 06 02:29 PM
doesnt work the preview in search mail function ----nikos 4000---- Outlook Express 1 July 26th 06 04:39 PM


All times are GMT +1. The time now is 08:54 PM.


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.