• Subject: Re: looping through inbox messages / debugger under Outlook VBA
  • Author: Sue Mosher [MVP-Outlook]
  • Date: 09 Apr 2008
  • References: 1
What I don't understand is why you're using a rule to fire off a process that iterates the entire Inbox. The whole point of a rule is to process the message that met the rule's conditions, i.e. the oItem object in your Sub's declaration. If you want to process all the items in a folder, don't use a rule for that, just write a normal macro.
Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54
"Mark VII" <MarkVII@discussions.microsoft.com> wrote in message news:594028BA-023B-4EB3-B783-807CCCF3D137@microsoft.com...
> Greetings -- > > I'm trying to automate the process of detecting certain incoming emails and > writing them out as plain text files under Outlook 2003. Am running into a > couple of problems. > > I have a rule pointing to a VBA subroutine, and the rule appears to trigger > when I use Run Rules Now. However, the VBA IDE does not behave as I am used > to in Access, Excel and Project. If I set a breakpoint, the code does not > break. Stop statements don't work either. Sometime a MsgBox statement will > pop a message box, sometimes not. Debug.Print statements sometime put > something in the Immediate window, something not. Not being able to set > breakpoints, view the content of variables, watch the loops loop, etc. is > making this very hard. > > The underlying task is to read through the messages in the inbox and write > the body of ones that contain a certain keyword out as plain text files. > Between what I've found on the net and my own knowledge of object models, > here's what I've got at this point. > > Public Sub ReadMessageBody(oItem As Outlook.MailItem) > > Dim strId As String > Dim oNameSpace As Outlook.NameSpace > Dim oInboxItem As Outlook.MailItem > Dim oMailItem As Outlook.MailItem > Dim oFolder As Outlook.MAPIFolder > Dim oMsg As Object > Dim strBody As String > > '* point to the name space > Set oNameSpace = Application.GetNamespace("MAPI") > > '* set a reference to the inbox folder > Set oFolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox) > > '* loop through the inbox > For Each oInboxItem In oFolder.Items > strId = oInboxItem.EntryID > > Set oMailItem = oNameSpace.GetItemFromID(strId) > If Left(oMailItem.Subject, 6) = "Deploy" Then > '* save message body as text > Else > '* something else, ignore > End If > Next oInboxItem > > End Sub > > As best I can determine with no debugging capability is that the sub is > called, but does not enter the For...Next loop. Also, it appears to fire > once per file in the Inbox. > > Can anyone give me any suggestions on how the use the IDE in Outlook? This > would be a lot easier to get working if I could used the debugger in the > usual fashion. > > Thanks a million...
09 Apr 2008looping through inbox messages / debugger under Outlook VBA.Mark VII
09 Apr 2008|- Re: looping through inbox messages / debugger under Outlook VBA.Ken Slovak - [MVP - O...
09 Apr 2008|  \ Re: looping through inbox messages / debugger under Outlook VBA.Mark VII
10 Apr 2008|     \ Re: looping through inbox messages / debugger under Outlook VBA.Ken Slovak - [MVP - O...
09 Apr 2008\ Re: looping through inbox messages / debugger under Outlook VBA.Sue Mosher [MVP-Outlook]
10 Apr 2008   \ Re: looping through inbox messages / debugger under Outlook VBA.Mark VII
10 Apr 2008      \ Re: looping through inbox messages / debugger under Outlook VBA.Sue Mosher [MVP-Outlook]
10 Apr 2008         \ Re: looping through inbox messages / debugger under Outlook VBA.Mark VII
All times are in (US) Eastern Daylight Time (GMT -4:00)