Bug in CDO messages collection when adding a new message?

Bug in CDO messages collection when adding a new message?

Post by Collin Peter » Thu, 15 Aug 2002 08:53:26



I have the following code:

  count = (long)pLstMessages->GetCount();
  newContact->Update( true, false );
  count = (long)pLstMessages->GetCount();

count is an int, pLstMessage is the message collection, and newContact is
the message being added.

At the first GetCount(), it returns a value of one which is correct as I can
alt-tab to outlook and verify that there is only one message.  When the
update() function is called the new record is added to Outlook and I can see
it when I alt-tab to Outlook.  However, the second GetCount() returns a
value of one again, instead of the correct two.

Is there some kind of refresh that I have to do?  Or is CDO just broken in
this regard?

Collin

 
 
 

Bug in CDO messages collection when adding a new message?

Post by Collin Peter » Thu, 15 Aug 2002 09:03:33


I've found that if I call GetMessages() again that the second GetCount()
will return 2 as it should.  This is a *huge* problem though as when you
perform that operation on the contacts folder it pops up that stupid
security dialog saying that someone is trying to access your address book.
Is there any other way of refreshing the data?

count = (long)pLstMessages->GetCount();
newContact->Update( true, false );
pLstMessages = pFolder->GetMessages() ;
count = (long)pLstMessages->GetCount();

Collin


Quote:> I have the following code:

>   count = (long)pLstMessages->GetCount();
>   newContact->Update( true, false );
>   count = (long)pLstMessages->GetCount();

> count is an int, pLstMessage is the message collection, and newContact is
> the message being added.

> At the first GetCount(), it returns a value of one which is correct as I
can
> alt-tab to outlook and verify that there is only one message.  When the
> update() function is called the new record is added to Outlook and I can
see
> it when I alt-tab to Outlook.  However, the second GetCount() returns a
> value of one again, instead of the correct two.

> Is there some kind of refresh that I have to do?  Or is CDO just broken in
> this regard?

> Collin


 
 
 

Bug in CDO messages collection when adding a new message?

Post by Daniel Mitchell [MVP » Fri, 16 Aug 2002 05:37:45




Quote:> I've found that if I call GetMessages() again that the second
> GetCount() will return 2 as it should.  This is a *huge* problem though
> as when you perform that operation on the contacts folder it pops up
> that stupid security dialog saying that someone is trying to access
> your address book. Is there any other way of refreshing the data?

 How are you getting the message list in the first place without calling
GetMessages() and getting the first warning dialog? Why can't you do
whatever you do there a second time?

 As for refreshing the data, I don't think there's any other way than
releasing and re-getting the object in question; CDO, as you've found,
caches some things locally, and it looks like this is a situation where it's
being over-zealous. You could try letting your message object go out of
scope and release, just in case the final reference you have to it's
confusing matters, perhaps?

 -- dan

 
 
 

Bug in CDO messages collection when adding a new message?

Post by Collin Peter » Sat, 17 Aug 2002 01:11:20



Quote:>  How are you getting the message list in the first place without calling
> GetMessages() and getting the first warning dialog? Why can't you do
> whatever you do there a second time?

 pFolder = pCDOSession->GetDefaultFolder( COleVariant( (SHORT)CDOType,
VT_I2 ) ) ;
 if (pFolder)
  pLstMessages = pFolder->GetMessages() ;

I am getting the first warning dialog, which I also hope to get rid of
sometime (by opening it via mapi if that is possible).  Having *another* one
pop up when you already said it could access it is twice the nuisance.

Quote:>  As for refreshing the data, I don't think there's any other way than
> releasing and re-getting the object in question; CDO, as you've found,
> caches some things locally, and it looks like this is a situation where
it's
> being over-zealous. You could try letting your message object go out of
> scope and release, just in case the final reference you have to it's
> confusing matters, perhaps?

Doesn't this strike you as odd?  Everything else in the CDO/MAPI
architecture seems to properly refresh itself.  However, I fixed my problem
by getting the new message by using pCDOSession->GetMessage( entryid,
storeid ).
 
 
 

Bug in CDO messages collection when adding a new message?

Post by Daniel Mitchell [MVP » Sat, 17 Aug 2002 02:30:35




Quote:> I am getting the first warning dialog, which I also hope to get rid of
> sometime (by opening it via mapi if that is possible).  Having
> *another* one pop up when you already said it could access it is twice
> the nuisance.

 Urg, I agree. People seem to be increasingly using auto-button-pushing
apps to get around this (I've heard ptfb being referred to a lot, though
I've never tried it myself)

Quote:> Doesn't this strike you as odd?  Everything else in the CDO/MAPI
> architecture seems to properly refresh itself.  However, I fixed my
> problem by getting the new message by using pCDOSession->GetMessage(
> entryid, storeid ).

 Yeah, there's weird glitches in CDO -- I'm not sure why this particular
one isn't updating properly. Does it happen if you do this on folders other
than the contacts -- perhaps it's that that's confusing things? (heck,
perhaps it's the security patch that broke it..)

 Good to hear you solved it, anyway -- sorry I couldn't be more helpful.

 -- dan

 
 
 

1. Strange error message CDO.Message.1: The

I am talk to CDO via cscript and am getting this error. I
am using an external mailserver and I guess its kicking
out the connection, could I use a try..catch type thing so
that the script doesn't fail but loops again and connects?

E:\Inetpub\customerroot\dotmailer.co.uk\www\mailer.vbs(21,
3) CDO.Message.1: The
 transport lost its connection to the server.

Simon

2. PPI: Looks like I need another modem recommendation...

3. add MIME X- Header to message using CDO 1.21

4. HELP? Newbie MIDI problem!

5. CDO: Add an outlook item by reference in a message

6. Presentation Maker?

7. Copying MAPI message properties to new message

8. Free fonts like Trajan

9. How to add additional Commands to Add-Ins (C++)

10. COM Add-in vs. Automation vs. Word Add-ins vs...

11. Adding new collection classes using templates

12. What are the new flags and messages in the new Common Control Dll released by MS?

13. Can't add new font, add new font not listed in font directory