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

Code Returning Half of the Values



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old December 20th 07, 07:55 PM posted to microsoft.public.outlook.program_vba
PJFry
external usenet poster
 
Posts: 14
Default Code Returning Half of the Values

I am running code that exports data releated to unread messages in an inbox.
What is puzzling me is that the code only returns half of the values that it
is supposed to. For example, if I have 50 unread messages, it will export
the data on the first 25 and stop. Any ideas what is causing this?

I am running OL 2003 on Windows XP Pro.

Sub SupplierSurvey()

With Application.Session

ExportMessageDetails .Folders("Mailbox - Quality
Department").Folders("Inbox")
End With
End Sub


Function ExportMessageDetails(vFolder As MAPIFolder) As Boolean
On Error GoTo Err_Handler
Kill "H:\SupplierSurvey.txt"

Dim vItem As Object, vFF As Long, vFile As String
vFF = FreeFile
vFile = "H:\SupplierSurvey.txt"
For Each vItem In vFolder.Items
If TypeName(vItem) = "MailItem" Then
If vItem.UnRead Then
Open vFile For Append As #vFF
Print #vFF, vFolder.Name & vbTab &
Format(vItem.ReceivedTime, "mm/dd/yyyy hh:mm:ss")

Close #vFF
End If

End If
Next

Err_Handler:
Resume Next

End Function

Thanks!

PJ
Ads
  #2  
Old December 20th 07, 09:12 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Code Returning Half of the Values

Strange. See what happens if you temporarily move 30 of those messages to
another folder and run your code again.

Also, remove the error handling so if any errors do occurr you'll know right
away.

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"PJFry" wrote:

I am running code that exports data releated to unread messages in an inbox.
What is puzzling me is that the code only returns half of the values that it
is supposed to. For example, if I have 50 unread messages, it will export
the data on the first 25 and stop. Any ideas what is causing this?

I am running OL 2003 on Windows XP Pro.

Sub SupplierSurvey()

With Application.Session

ExportMessageDetails .Folders("Mailbox - Quality
Department").Folders("Inbox")
End With
End Sub


Function ExportMessageDetails(vFolder As MAPIFolder) As Boolean
On Error GoTo Err_Handler
Kill "H:\SupplierSurvey.txt"

Dim vItem As Object, vFF As Long, vFile As String
vFF = FreeFile
vFile = "H:\SupplierSurvey.txt"
For Each vItem In vFolder.Items
If TypeName(vItem) = "MailItem" Then
If vItem.UnRead Then
Open vFile For Append As #vFF
Print #vFF, vFolder.Name & vbTab &
Format(vItem.ReceivedTime, "mm/dd/yyyy hh:mm:ss")

Close #vFF
End If

End If
Next

Err_Handler:
Resume Next

End Function

Thanks!

PJ

  #3  
Old December 20th 07, 11:56 PM posted to microsoft.public.outlook.program_vba
PJFry
external usenet poster
 
Posts: 14
Default Code Returning Half of the Values

Figures it out. What I was trying to do was count the number of unread
items, specifically Undeliverable mail. In this case, exactly half of the
messages were undeliverable. The code is supposed to look at MailItems,
which I am guessing undeliverable mail is not. Once I cleared those message
out, I got the result I was expecting.

So that begs the question, what kind of an item is undeliverable mail?

"PJFry" wrote:

I am running code that exports data releated to unread messages in an inbox.
What is puzzling me is that the code only returns half of the values that it
is supposed to. For example, if I have 50 unread messages, it will export
the data on the first 25 and stop. Any ideas what is causing this?

I am running OL 2003 on Windows XP Pro.

Sub SupplierSurvey()

With Application.Session

ExportMessageDetails .Folders("Mailbox - Quality
Department").Folders("Inbox")
End With
End Sub


Function ExportMessageDetails(vFolder As MAPIFolder) As Boolean
On Error GoTo Err_Handler
Kill "H:\SupplierSurvey.txt"

Dim vItem As Object, vFF As Long, vFile As String
vFF = FreeFile
vFile = "H:\SupplierSurvey.txt"
For Each vItem In vFolder.Items
If TypeName(vItem) = "MailItem" Then
If vItem.UnRead Then
Open vFile For Append As #vFF
Print #vFF, vFolder.Name & vbTab &
Format(vItem.ReceivedTime, "mm/dd/yyyy hh:mm:ss")

Close #vFF
End If

End If
Next

Err_Handler:
Resume Next

End Function

Thanks!

PJ

  #4  
Old December 21st 07, 12:10 AM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Code Returning Half of the Values

If it passes the MailItem test it will be some variation of *.IPM.Note.*.
You can set the folder to a bottom reading pane view and customize the view
to see the exact MessageClass. Depending on the server and the source of the
message it could really be anything.

An undeliverable message that I get from my Exchange server has a
MessageClass of "REPORT.IPM.Note.NDR"

--
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


"PJFry" wrote in message
...
Figures it out. What I was trying to do was count the number of unread
items, specifically Undeliverable mail. In this case, exactly half of the
messages were undeliverable. The code is supposed to look at MailItems,
which I am guessing undeliverable mail is not. Once I cleared those
message
out, I got the result I was expecting.

So that begs the question, what kind of an item is undeliverable mail?


 




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
CompareEntryIDs is returning bogus results Count Infinity Add-ins for Outlook 4 October 19th 07 03:19 AM
Close method returning 80040108 Michael Tissington Add-ins for Outlook 4 February 14th 07 01:03 AM
WDS not returning Office 2007 emails on Windows XP BerkHolz, Steven Outlook - General Queries 5 January 12th 07 08:28 PM
deleted emails returning David Outlook - General Queries 0 March 30th 06 06:09 PM
Old Reminders Keep Returning Anita Taylor Outlook - Calandaring 0 March 9th 06 04:11 PM


All times are GMT +1. The time now is 09:52 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.