Solved

Using Outlook and VBA to automate an email application, having trouble cycling through Inbox...

Posted on 2003-10-29
3
657 Views
Last Modified: 2011-10-03
Hello,
I have written some VBA that is triggered when an email comes into the Inbox (outlook 2000).  The VBA connects to a DB, finds some information, then responds to the email with that information.  That email is then moved to a different folder in Outlook. Then, I have query that checks the Inbox to see if there are more emails.  if there is one, a variable grabs the top record (the first email in the Inbox), and assigns it to an Object variable.  

The problem:

olInboxItems_ItemAdd(ByVal Item As Object)

seems to not want to let me call it again and pass the next email to it.  I am trying to figure out how to get the VBA to cycle through the emails of there are more in the inbox.  

This is where I query the inbox, assign the next email to the variable, and pass it through... all i keep getting is "Object required" Error no matter what i try:
(Dims)
objNS2 is a Namespace
myFolder is a MAPIFolder
tempItem is an Object

----****other code****----
Set objNS2 = Application.GetNamespace("MAPI")
Set myFolder = objNS2.GetDefaultFolder(olFolderInbox)

'assign the next email to tempItem
Set tempItem = myFolder.Items(1)

'pass tempItem to the original function to start the process again with a new email
olInboxItems_ItemAdd (tempItem)
----****other code****----

I AM DESPERATE!!!!!!  Can you help?

Thank you SOOOOOOOOOOO much for your help!

Eric

PS... the few times it accepted something, it simply used the original email and never picked up the new one... then after two more lines, it crashed. hope this doesnt confuse!
0
Comment
Question by:ajet7
3 Comments
 
LVL 9

Accepted Solution

by:
rjcpjc earned 305 total points
ID: 9646706
This function fires once for every email received. You should be using the intrinsic Item object. You shouldn't need to run the code multiple times as the code should run once for every email that's received.  The function isn't designed to be called from itself.

That benig said, VBA code in Outlook isn't a 100% guarantee either :-/
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Get an idea of what you should include in an email disclaimer with these Top 5 email disclaimer tips.
Outlook Free & Paid Tools
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now