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

Outlook not processing all email items



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 26th 12, 10:11 PM
Jon Mortimer Jon Mortimer is offline
Junior Member
 
First recorded activity at Outlookbanter: Nov 2012
Posts: 2
Talking Outlook not processing all email items

Hi, I have an issue. I have a script that is very basic in my opinion, it looks at all the emails in a certain folder, checks the Subject for a keyword and based on this files it in a specific folder. Everything works perfect except, out of 10 messages - for example - it only processes 5-7 of them. If I run the macro again, it does a few more, etc. Eventually all are processed but I don't understand what I'm doing wrong that it doesn't cycle through all of them. I was hoping someone could take a look at this code to see where I might be going wrong. This code is from a much larger script but this is the important part related to the issue.

Code:
Public appOl As New Outlook.Application
Public ns As Outlook.NameSpace
Public Inbox As Outlook.MAPIFolder
Public DestFolder As Outlook.MAPIFolder
Public Atmt As Outlook.Attachment
Public olApp As Outlook.Application
Public olNewMail As Outlook.MailItem
Public Item As Object

Private Sub Check_Support_Mailbox()
   On Error GoTo Check_Support_Mailbox_err
  Dim subText As String
   Set ns = appOl.GetNamespace("MAPI")
   Set Inbox = ns.Folders("Mailbox - MyName").Folders("Inbox")
   '
   For Each Item In Inbox.Items.Restrict("[UnRead] = True")
      ' Added this flag to see if it was looking at each msgs
      ' Based on this flag, it is not touching every email
      Item.FlagIcon = olYellowFlagIcon
      If (Item.Class = olMail) And (Item.UnRead) Then
         '
         ' I removed the reference to all states, 3 is a good sampling
         '
         If InStr(Item.Subject, "AL -")  0 Then NorthIncidents
        If InStr(Item.Subject, "AZ -")  0 Then WestIncidents
         If InStr(Item.Subject, "AR -")  0 Then EastIncidents
      End If
   Next Item
Check_Support_Mailbox_exit:
   Set Atmt = Nothing
   Set Item = Nothing
   Set ns = Nothing
   Set appOl = Nothing
   Exit Sub
Check_Support_Mailbox_err:
   MsgBox "Error has occurred " & Err.Number & “: “ & Err.Description, vbCritical, "Error!"
   Resume Process_Report_Emails_exit
End Sub
Also, maybe someone could offer a better solution for how I'm handling the keyword search? Basically, I'm looking for the STATE abbreviation in the subject line and based on that files it appropriately. Obviously 50 IfThen statements makes no sense but I just couldn't figure a better way.

THANKS FOR ANY ASSISTANCE!!!
Ads
  #2  
Old December 4th 12, 06:32 PM
Jon Mortimer Jon Mortimer is offline
Junior Member
 
First recorded activity at Outlookbanter: Nov 2012
Posts: 2
Default

Quote:
Originally Posted by Jon Mortimer View Post
Hi, I have an issue. I have a script that is very basic in my opinion, it looks at all the emails in a certain folder, checks the Subject for a keyword and based on this files it in a specific folder.
I'm bumping this message in the hopes that someone will be able to help me on this. I'm surprised there hasn't been a response already but hope someone has had a similar problem and might have some information on how to fix it, or point me in a new direction.
 




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
Processing Email Messages in .pst, changing email addresses akumar Add-ins for Outlook 5 August 27th 09 03:08 PM
Outlook 2007 shuts down when processing scheduled calendar items Peter Outlook - Calandaring 0 September 4th 08 05:46 PM
Processing items in the outbox Richard Add-ins for Outlook 4 May 20th 08 01:20 AM
Outlook COM Addins order of processing Kevin Add-ins for Outlook 1 February 5th 08 05:24 PM
receiving email never finishes processing Regina Outlook - General Queries 0 May 24th 06 02:45 PM


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