Sent via Deja.com http://www.deja.com/
Before you buy.
--
Danny J. Lesandrini
dan_n...@yahoo.com
<vbro...@my-deja.com> wrote in message news:8cr80a$cd0$1...@nnrp1.deja.com...
-- Dev
In article <8cshpu$6uufh$1...@fu-berlin.de>,
It sounds like the problem is with the loop not the message reading
code. It looks like you are processing every second message. Check for
anything that might affect the loop counter. This might be a dumb
question but do you use Next as well as i=i+1 in the loop? or anything
that changes the loop counter variable? If this isn't the problem you
might consider posting the actual code you are using so that everyone
can see exactly what you are doing.
Bri
Public Function CheckAttachments()
On Error Resume Next
Dim objOutlook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objItems As Outlook.Items
Dim objMail As Object
Dim lngRetVal As Long
Dim intRecCount As Integer
Dim objAttachments As Outlook.Attachments
Dim objMessage As Outlook.MailItem
Dim SigningInbox As Outlook.MAPIFolder
Dim intCounter As Integer
Dim intItemCount As Integer
'check to see if Outlook is already open
lngRetVal = FindWindowByClass("rctrl_renwnd32", 0&)
'if Outlook is open, get the existing object, otherwise create new
object
If lngRetVal <> 0 Then
Set objOutlook = GetObject(, "outlook.application")
Else
Set objOutlook = CreateObject("outlook.application")
End If
'create objects to find a mail item
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objItems = objNameSpace.GetDefaultFolder(olFolderInbox).Items
'intItemCount = objItems.Count
Set objMail = objItems.GetFirst
Do While Not objMail Is Nothing
objMail.Display
Set objMessage = objOutlook.ActiveInspector.CurrentItem
Set objAttachments = objMessage.Attachments
If objAttachments.Count = 0 Then
'move the message to the appropriate folder
Else
'depending on name of attachment, call import function
End If
Set objMail = objItems.GetNext
Loop
Set objAttachments = Nothing
Set objMessage = Nothing
Set objMail = Nothing
Set objItems = Nothing
Set objNameSpace = Nothing
Set objOutlook = Nothing
End Function
In article <38F3523F...@here.com>,
Bri <n...@here.com> wrote:
> Hi there,
>
> It sounds like the problem is with the loop not the message reading
> code. It looks like you are processing every second message. Check for
> anything that might affect the loop counter. This might be a dumb
> question but do you use Next as well as i=i+1 in the loop? or anything
> that changes the loop counter variable? If this isn't the problem you
> might consider posting the actual code you are using so that everyone
> can see exactly what you are doing.
>
> Bri
>
Wow, my news server must not like you. Your message, dated Apr 14,
didn't show up on my server until today, Apr 19.
I think I see what might be happening. When you 'move' the message to
another folder then there is no record for the curser to sit on anymore
so it moves to the next record. You then issue a 'GetNext'. Since it is
already on the next message it skips it and you get the second one. Try
commenting out the 'GetNext' to see if this is the problem.
This is just a guess you realize, but it is the only explaination that I
can come up with without trying the code out myself.
Bri
A day or two after I posted the code, I actually thought that moving
the message is probably what's causing the problem. Unfortunately,
though, commenting out the GetNext doesn't fix it. When I comment it
out, it actually displays the message it just supposedly moved again
and again, and somehow puts multiple copies of the same message into
the new folder. So, it's gone from the inbox, but it still considers
that message to be the active item. The other thing I noticed is that
it is not consistent as to which message comes up as the GetFirst. I
keep my messages in descending order by receipt date (so most recent
first), and sometimes it goes to the last message in the inbox first,
and sometimes it picks a message in the middle of the inbox. Even when
it picks the last message in the inbox first, it still manages to check
a few more messages and then exits the loop w/ out error. At this
point, I'm totally confused and frustrated because it seems that the
behavior is not consistent. If you have any other thoughts on this,
I'd really appreciate it because I would hate to think I'm going to
have to tell my user, "Oh, it's OK, just hit the button a few times to
make sure you got all the messages." Gee, that's really
professional... Once again, thanks for the help! :-) Victoria
In article <38FDCE9A...@here.com>,
Bri <n...@here.com> wrote:
> Hi there,
>
How about trying a slightly different approach? Instead of moving the
message to the folder, just copy it. If all of the messages are now
processed then it is the move that is causing the problems. There might
be another way to do the move that behaves differently.
An immediate solution would be to enclose your loop in another loop that
tests for zero messages in the inbox. This would process all of the
messages in multiple passes. It still seems like a strange scenario, but
this would kludge it into working.
Of course the best thing would be to identify why the move both leaves
the pointer on the moved message and skips one when you move to the next
message. Since I have not yet written any code to process Outlook
messages, I don't have any first hand experience that would provide more
insight. I only can conclude that there is something happening in the
loop (skipping records) from the symptoms you described. One of these
days I will have to write similar code (a client has hinted at wanting
to unify their Access Contact list with their Outlook Contact List) so I
will probably find myself in the same place you are in now. If you do
eventually find the real glitch, please post the solution. In the mean
time you can still deliver the desired behavior (from the users
perspective) by using the kludge above.
Hope this helps, good luck.
Bri
Thanks for all your help. Once again it seems we are thinking along
the same lines (i.e., "tricking" Outlook into checking all the
messages). I'll give that a try this afternoon. And, of course, if I
find the "real" solution, I will post it here. I'm not holding my
breath though... :-)
In article <39008922...@here.com>,
I was following another thread and in it Michka pointed out something
that is the solution to your problem. As I suspected, moving the message
(the equivelent of 'closing the Form' in the other thread) confuses the
pointer. Michka's solution is to use a FOR/NEXT loop that loops
BACKWARDS through the items so that the pointer is always moving records
whose position hasn't been altered by the close (or move in your case).
So:
CODE START
==========
for i= intItemCount To 1 step -1 ' was: Do While Not objMail Is
Nothing
objMail.Display
Set objMessage = objOutlook.ActiveInspector.CurrentItem
Set objAttachments = objMessage.Attachments
If objAttachments.Count = 0 Then
'move the message to the appropriate folder
Else
'depending on name of attachment, call import function
End If
' no longer required: Set objMail = objItems.GetNext
next ' was: Loop
CODE END
========
Give this a shot. I have pasted in the message from the other thread for
you below.
Bri.
=======================================
Subject: Re: Using DAO to Step Through Forms
Date: Thu, 27 Apr 2000 05:56:07 -0700
From: "Michael \(michka\) Kaplan"
<forme...@spamfree.trigeminal.nospam.com>
Organization: Trigeminal Software, Inc.
Newsgroups: comp.databases.ms-access
No, you should not do this, as it will not close all the forms, since
the
iterator loses its place and closes every other form. You should count
backwards in a For...Next loop.
--
MichKa
"Cause it's a bittersweet symphony, thats life..." -- The Verve
random junk of dubious value, at the multilingual,
no scripts required, http://www.trigeminal.com/
"Wolfgang Stein" <wolfgan...@gabo.de> wrote in message
news:sggcme...@corp.supernews.com...
> Hi,
> try this:
>
> Dim frm As Form
>
> DoCmd.Close 'Closes form with the focus
>
> For Each frm In Forms
> If frm.Visible = False Then
> DoCmd.Close acForm, frm.Name
> End If
> Next
>
> Josh wrote:
> >
> > Hi,
> >
> > I have 3 forms that I toggle between Visible and not Visible. Only 1
> > form has it's visible property set to true at any given time, but
> > neither, either, or both of the other forms can be open but invisible.
> > On each form, I have an exit button that I need to close the visible
> > form and any open, but invisible forms.
> >
> > My logic was to loop through each form in the database, and if the
> > visible property is false, close the form.
> >
> > I attempted the following code on the click event of the exit button:
> >
> > Dim frm as Form
> >
> > Docmd.Close 'Closes form with the focus
> >
> > 'Meant to close open, but invisible forms, but doesn't work.
> > For Each frm In CurrentDb().Containers!Forms
> > If frm.Visible = False Then
> > DoCmd.Close acForm, frm
> > End If
> > Next
> >
> > Unfortunatly, I get an error saying that "Operation is not supported
> > for this type of object". Is my syntax correct? Can anyone think of
> > an easier way to handle this?
> >
> > TIA,
> > Josh
*****IT WORKS!!!!!!!!*******
*****IT WORKS!!!!!!!!*******
*****IT WORKS!!!!!!!!*******
At first I tried it and it didn't work, but it turned out it was
because the objItems.Item(index) is 1-based NOT zero-based as I had
originally tried. I can't believe it actually worked!! Hooray!!
Here is the new code:
========
intItemCount = objItems.Count
For intCounter = intItemCount To 1 Step -1
Set objMail = objItems.Item(intCounter)
objMail.Display
Set objMessage = objOutlook.ActiveInspector.CurrentItem
Set objAttachments = objMessage.Attachments
If objAttachments.Count = 0 Then
'move the message to the appropriate folder
Else
'import and move
End If
Next
==========
Thanks again!!
-Victoria
In article <3909D86E...@here.com>,
Bri <n...@here.com> wrote:
> Victoria,
>
> I was following another thread and in it Michka pointed out something
> that is the solution to your problem. As I suspected, moving the
message
> (the equivelent of 'closing the Form' in the other thread) confuses
the
> pointer. Michka's solution is to use a FOR/NEXT loop that loops
> BACKWARDS through the items so that the pointer is always moving
records
> whose position hasn't been altered by the close (or move in your
case).
> So:
>
> CODE START
> ==========
>
> for i= intItemCount To 1 step -1 ' was: Do While Not objMail Is
> Nothing
> objMail.Display
> Set objMessage = objOutlook.ActiveInspector.CurrentItem
> Set objAttachments = objMessage.Attachments
>
> If objAttachments.Count = 0 Then
> 'move the message to the appropriate folder
> Else
> 'depending on name of attachment, call import function
> End If
> ' no longer required: Set objMail = objItems.GetNext
> next ' was: Loop
>
> CODE END
> ========
>
> Give this a shot. I have pasted in the message from the other thread
for
> you below.
>
> Bri.
>