Manual UnRead and item state after that.

  • Thread starter Thread starter Vladimir Chtchetkine
  • Start date Start date
V

Vladimir Chtchetkine

I'll rephrase the question because it's still the biggest issue on my plate.
If I "UnRead" selected (it's important part) item manually (i.e. through the
item's or folder's context menu "Mark as read" ) I can't save [asynchronous]
changes to that item (at least changes made to item's UserProperties"). I
can change properties successfully, but when I call Save on the item I get
an error. The error message varies from "unknown error" in outl2K to
"message has changed" in outl2K3. But in both cases item fails to save.
Asynchronous means that these changes (that I try to save) are made not
though the Outl UI but came from some async event (of course I sync that
event back to a UI thread and whole 9 yards but still, in essence changes
are asynchronous).

However, after I change selection in Explorer (i.e. after I select another
item) changes and save on the problematic item start going through just
fine. Until next time I select it and "Mark as read".



Please advice. This is really killing me.



TIA,



Vladimir
 
OK, Some more food for thoughts :-)

When my call to PostItem.Save() routine fails I get item's IMAPIProp
interface (through its MAPIOBJECT property) and call
SaveChanges(KEEP_OPEN_READWRITE) on it. No surprise this call fails :-) with
an error MAPI_E_OBJECT_CHANGED. Does this ring any bell to anyone?
Now, just for sake of experiment, when I get MAPI_E_OBJECT_CHANGED error
from SaveChanges I immediately repeat SaveChanges but this time with
FORCE_SAVE flag. And this succeds... But this creates problems of its own
(FORCE_SAVE closes the item and I need to "reopen" it).

So, with this additional info can anyone advice me on what's the most
gracefull way around that problem? How do I sync changes to the item from
different sources?

TIA,

Vladimir
 
The errror essentially says that the object had been modified *after* you
opened it. To avoid this error, do *not* keep any items cached (referenced)
for longer than you need to. Store the entry id instead, open the item using
Namespace.GetItemFromID, modify it, release.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Vladimir Chtchetkine said:
OK, Some more food for thoughts :-)

When my call to PostItem.Save() routine fails I get item's IMAPIProp
interface (through its MAPIOBJECT property) and call
SaveChanges(KEEP_OPEN_READWRITE) on it. No surprise this call fails :-)
with
an error MAPI_E_OBJECT_CHANGED. Does this ring any bell to anyone?
Now, just for sake of experiment, when I get MAPI_E_OBJECT_CHANGED error
from SaveChanges I immediately repeat SaveChanges but this time with
FORCE_SAVE flag. And this succeds... But this creates problems of its own
(FORCE_SAVE closes the item and I need to "reopen" it).

So, with this additional info can anyone advice me on what's the most
gracefull way around that problem? How do I sync changes to the item from
different sources?

TIA,

Vladimir
Vladimir Chtchetkine said:
I'll rephrase the question because it's still the biggest issue on my plate.
If I "UnRead" selected (it's important part) item manually (i.e. through the
item's or folder's context menu "Mark as read" ) I can't save [asynchronous]
changes to that item (at least changes made to item's UserProperties"). I
can change properties successfully, but when I call Save on the item I
get
an error. The error message varies from "unknown error" in outl2K to
"message has changed" in outl2K3. But in both cases item fails to save.
Asynchronous means that these changes (that I try to save) are made not
though the Outl UI but came from some async event (of course I sync that
event back to a UI thread and whole 9 yards but still, in essence changes
are asynchronous).

However, after I change selection in Explorer (i.e. after I select
another
item) changes and save on the problematic item start going through just
fine. Until next time I select it and "Mark as read".



Please advice. This is really killing me.



TIA,



Vladimir
 
Well, subject is semi-closed :-)

It turned out that KEEP_OPEN_READWRITE and FORCE_SAVE are not mutually
exclusive but rather or'ed flags. So if I pass both of them item gets saved
and remains opened.
What bothers me though is that there is another object "hanging around" and
who knows what surprises this object may throw... Is there any way to
determine all objects that are opened for a particular item's EntryID and
flush them before I start doing my changes to the item?

TIA,

Vladimir

Vladimir Chtchetkine said:
OK, Some more food for thoughts :-)

When my call to PostItem.Save() routine fails I get item's IMAPIProp
interface (through its MAPIOBJECT property) and call
SaveChanges(KEEP_OPEN_READWRITE) on it. No surprise this call fails :-) with
an error MAPI_E_OBJECT_CHANGED. Does this ring any bell to anyone?
Now, just for sake of experiment, when I get MAPI_E_OBJECT_CHANGED error
from SaveChanges I immediately repeat SaveChanges but this time with
FORCE_SAVE flag. And this succeds... But this creates problems of its own
(FORCE_SAVE closes the item and I need to "reopen" it).

So, with this additional info can anyone advice me on what's the most
gracefull way around that problem? How do I sync changes to the item from
different sources?

TIA,

Vladimir
Vladimir Chtchetkine said:
I'll rephrase the question because it's still the biggest issue on my plate.
If I "UnRead" selected (it's important part) item manually (i.e. through the
item's or folder's context menu "Mark as read" ) I can't save [asynchronous]
changes to that item (at least changes made to item's UserProperties"). I
can change properties successfully, but when I call Save on the item I get
an error. The error message varies from "unknown error" in outl2K to
"message has changed" in outl2K3. But in both cases item fails to save.
Asynchronous means that these changes (that I try to save) are made not
though the Outl UI but came from some async event (of course I sync that
event back to a UI thread and whole 9 yards but still, in essence changes
are asynchronous).

However, after I change selection in Explorer (i.e. after I select another
item) changes and save on the problematic item start going through just
fine. Until next time I select it and "Mark as read".



Please advice. This is really killing me.



TIA,



Vladimir
 
Nope, there is no way to find out if other instances of the same object are
open through MAPI. Outlook though does cache the items, so a particular item
won't be opened more than once.
Again, do not cache the items in your code, reopen them as necessary using
GetItemFomID.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Vladimir Chtchetkine said:
Well, subject is semi-closed :-)

It turned out that KEEP_OPEN_READWRITE and FORCE_SAVE are not mutually
exclusive but rather or'ed flags. So if I pass both of them item gets
saved
and remains opened.
What bothers me though is that there is another object "hanging around"
and
who knows what surprises this object may throw... Is there any way to
determine all objects that are opened for a particular item's EntryID and
flush them before I start doing my changes to the item?

TIA,

Vladimir

Vladimir Chtchetkine said:
OK, Some more food for thoughts :-)

When my call to PostItem.Save() routine fails I get item's IMAPIProp
interface (through its MAPIOBJECT property) and call
SaveChanges(KEEP_OPEN_READWRITE) on it. No surprise this call fails :-) with
an error MAPI_E_OBJECT_CHANGED. Does this ring any bell to anyone?
Now, just for sake of experiment, when I get MAPI_E_OBJECT_CHANGED error
from SaveChanges I immediately repeat SaveChanges but this time with
FORCE_SAVE flag. And this succeds... But this creates problems of its own
(FORCE_SAVE closes the item and I need to "reopen" it).

So, with this additional info can anyone advice me on what's the most
gracefull way around that problem? How do I sync changes to the item from
different sources?

TIA,

Vladimir
message
I'll rephrase the question because it's still the biggest issue on my plate.
If I "UnRead" selected (it's important part) item manually (i.e.
through the
item's or folder's context menu "Mark as read" ) I can't save [asynchronous]
changes to that item (at least changes made to item's UserProperties"). I
can change properties successfully, but when I call Save on the item I get
an error. The error message varies from "unknown error" in outl2K to
"message has changed" in outl2K3. But in both cases item fails to save.
Asynchronous means that these changes (that I try to save) are made not
though the Outl UI but came from some async event (of course I sync
that
event back to a UI thread and whole 9 yards but still, in essence changes
are asynchronous).

However, after I change selection in Explorer (i.e. after I select another
item) changes and save on the problematic item start going through just
fine. Until next time I select it and "Mark as read".



Please advice. This is really killing me.



TIA,



Vladimir
 
Dmitry:

That's the problemo! :-)

I need to monitor for attachments being read. I store attachments somewhere
else and bring them locally "on demand". And to catch that "demand" I need
to hookup to AttachmentRead event which (hooking to this event) will
reference that item. Plus, I may have this item opened in Inspector, etc...

Since all (oh, well, almost all, at least user-meaningful) access to the
item goes through my addin code I can manage and sync my own item
"pseudo-cache" (and that's what I actually do). And I don't mind much
overriding "external" changes (so far it's only marking item as
read/unread). Unless there are changes that will screw everything up. If you
know those types of changes please let me know!



TIA,



Vladimir



Dmitry Streblechenko said:
Nope, there is no way to find out if other instances of the same object are
open through MAPI. Outlook though does cache the items, so a particular item
won't be opened more than once.
Again, do not cache the items in your code, reopen them as necessary using
GetItemFomID.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Vladimir Chtchetkine said:
Well, subject is semi-closed :-)

It turned out that KEEP_OPEN_READWRITE and FORCE_SAVE are not mutually
exclusive but rather or'ed flags. So if I pass both of them item gets
saved
and remains opened.
What bothers me though is that there is another object "hanging around"
and
who knows what surprises this object may throw... Is there any way to
determine all objects that are opened for a particular item's EntryID and
flush them before I start doing my changes to the item?

TIA,

Vladimir

OK, Some more food for thoughts :-)

When my call to PostItem.Save() routine fails I get item's IMAPIProp
interface (through its MAPIOBJECT property) and call
SaveChanges(KEEP_OPEN_READWRITE) on it. No surprise this call fails :-) with
an error MAPI_E_OBJECT_CHANGED. Does this ring any bell to anyone?
Now, just for sake of experiment, when I get MAPI_E_OBJECT_CHANGED error
from SaveChanges I immediately repeat SaveChanges but this time with
FORCE_SAVE flag. And this succeds... But this creates problems of its own
(FORCE_SAVE closes the item and I need to "reopen" it).

So, with this additional info can anyone advice me on what's the most
gracefull way around that problem? How do I sync changes to the item from
different sources?

TIA,

Vladimir
message
I'll rephrase the question because it's still the biggest issue on my
plate.
If I "UnRead" selected (it's important part) item manually (i.e.
through
the
item's or folder's context menu "Mark as read" ) I can't save
[asynchronous]
changes to that item (at least changes made to item's
UserProperties").
I
can change properties successfully, but when I call Save on the item
I
get
an error. The error message varies from "unknown error" in outl2K to
"message has changed" in outl2K3. But in both cases item fails to save.
Asynchronous means that these changes (that I try to save) are made not
though the Outl UI but came from some async event (of course I sync
that
event back to a UI thread and whole 9 yards but still, in essence changes
are asynchronous).

However, after I change selection in Explorer (i.e. after I select another
item) changes and save on the problematic item start going through just
fine. Until next time I select it and "Mark as read".



Please advice. This is really killing me.



TIA,



Vladimir
 
Then you are probably out of luck... Were you able to identify what exactly
modifies the message that you are monitoring?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Vladimir Chtchetkine said:
Dmitry:

That's the problemo! :-)

I need to monitor for attachments being read. I store attachments
somewhere
else and bring them locally "on demand". And to catch that "demand" I need
to hookup to AttachmentRead event which (hooking to this event) will
reference that item. Plus, I may have this item opened in Inspector,
etc...

Since all (oh, well, almost all, at least user-meaningful) access to the
item goes through my addin code I can manage and sync my own item
"pseudo-cache" (and that's what I actually do). And I don't mind much
overriding "external" changes (so far it's only marking item as
read/unread). Unless there are changes that will screw everything up. If
you
know those types of changes please let me know!



TIA,



Vladimir



Dmitry Streblechenko said:
Nope, there is no way to find out if other instances of the same object are
open through MAPI. Outlook though does cache the items, so a particular item
won't be opened more than once.
Again, do not cache the items in your code, reopen them as necessary
using
GetItemFomID.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

message
Well, subject is semi-closed :-)

It turned out that KEEP_OPEN_READWRITE and FORCE_SAVE are not mutually
exclusive but rather or'ed flags. So if I pass both of them item gets
saved
and remains opened.
What bothers me though is that there is another object "hanging around"
and
who knows what surprises this object may throw... Is there any way to
determine all objects that are opened for a particular item's EntryID and
flush them before I start doing my changes to the item?

TIA,

Vladimir

OK, Some more food for thoughts :-)

When my call to PostItem.Save() routine fails I get item's IMAPIProp
interface (through its MAPIOBJECT property) and call
SaveChanges(KEEP_OPEN_READWRITE) on it. No surprise this call fails
:-)
with
an error MAPI_E_OBJECT_CHANGED. Does this ring any bell to anyone?
Now, just for sake of experiment, when I get MAPI_E_OBJECT_CHANGED error
from SaveChanges I immediately repeat SaveChanges but this time with
FORCE_SAVE flag. And this succeds... But this creates problems of its own
(FORCE_SAVE closes the item and I need to "reopen" it).

So, with this additional info can anyone advice me on what's the most
gracefull way around that problem? How do I sync changes to the item from
different sources?

TIA,

Vladimir
message
I'll rephrase the question because it's still the biggest issue on
my
plate.
If I "UnRead" selected (it's important part) item manually (i.e.
through
the
item's or folder's context menu "Mark as read" ) I can't save
[asynchronous]
changes to that item (at least changes made to item's UserProperties").
I
can change properties successfully, but when I call Save on the item I
get
an error. The error message varies from "unknown error" in outl2K to
"message has changed" in outl2K3. But in both cases item fails to save.
Asynchronous means that these changes (that I try to save) are made not
though the Outl UI but came from some async event (of course I sync
that
event back to a UI thread and whole 9 yards but still, in essence
changes
are asynchronous).

However, after I change selection in Explorer (i.e. after I select
another
item) changes and save on the problematic item start going through just
fine. Until next time I select it and "Mark as read".



Please advice. This is really killing me.



TIA,



Vladimir
 
I have no idea what exactly modifies it. The closest guess I can make is
"Outlook" :-) The event that causes modification is context menu's "Mark as
read" command. What is interesting tough is that before "Mark as read" is
executed the item has been in a "saved" state but when (whatever it is that
does that) "Mark as read" is executed changes that were involved in that
command are not saved (for the lack of better term). You can see it yourself
with the spy. Open an item in spy, look at UnRead property, mark that item
as read/unread (just reverse the state), refresh properties in the spy
window, look again at UnRead and you will see that it has not been changed.

Dmitry Streblechenko said:
Then you are probably out of luck... Were you able to identify what exactly
modifies the message that you are monitoring?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Vladimir Chtchetkine said:
Dmitry:

That's the problemo! :-)

I need to monitor for attachments being read. I store attachments
somewhere
else and bring them locally "on demand". And to catch that "demand" I need
to hookup to AttachmentRead event which (hooking to this event) will
reference that item. Plus, I may have this item opened in Inspector,
etc...

Since all (oh, well, almost all, at least user-meaningful) access to the
item goes through my addin code I can manage and sync my own item
"pseudo-cache" (and that's what I actually do). And I don't mind much
overriding "external" changes (so far it's only marking item as
read/unread). Unless there are changes that will screw everything up. If
you
know those types of changes please let me know!



TIA,



Vladimir



Dmitry Streblechenko said:
Nope, there is no way to find out if other instances of the same object are
open through MAPI. Outlook though does cache the items, so a particular item
won't be opened more than once.
Again, do not cache the items in your code, reopen them as necessary
using
GetItemFomID.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

message
Well, subject is semi-closed :-)

It turned out that KEEP_OPEN_READWRITE and FORCE_SAVE are not mutually
exclusive but rather or'ed flags. So if I pass both of them item gets
saved
and remains opened.
What bothers me though is that there is another object "hanging around"
and
who knows what surprises this object may throw... Is there any way to
determine all objects that are opened for a particular item's EntryID and
flush them before I start doing my changes to the item?

TIA,

Vladimir

OK, Some more food for thoughts :-)

When my call to PostItem.Save() routine fails I get item's IMAPIProp
interface (through its MAPIOBJECT property) and call
SaveChanges(KEEP_OPEN_READWRITE) on it. No surprise this call fails
:-)
with
an error MAPI_E_OBJECT_CHANGED. Does this ring any bell to anyone?
Now, just for sake of experiment, when I get MAPI_E_OBJECT_CHANGED error
from SaveChanges I immediately repeat SaveChanges but this time with
FORCE_SAVE flag. And this succeds... But this creates problems of
its
own
(FORCE_SAVE closes the item and I need to "reopen" it).

So, with this additional info can anyone advice me on what's the most
gracefull way around that problem? How do I sync changes to the item from
different sources?

TIA,

Vladimir
message
I'll rephrase the question because it's still the biggest issue on
my
plate.
If I "UnRead" selected (it's important part) item manually (i.e.
through
the
item's or folder's context menu "Mark as read" ) I can't save
[asynchronous]
changes to that item (at least changes made to item's UserProperties").
I
can change properties successfully, but when I call Save on the
item
I
get
an error. The error message varies from "unknown error" in outl2K to
"message has changed" in outl2K3. But in both cases item fails to save.
Asynchronous means that these changes (that I try to save) are
made
not
though the Outl UI but came from some async event (of course I sync
that
event back to a UI thread and whole 9 yards but still, in essence
changes
are asynchronous).

However, after I change selection in Explorer (i.e. after I select
another
item) changes and save on the problematic item start going through just
fine. Until next time I select it and "Mark as read".



Please advice. This is really killing me.



TIA,



Vladimir
 
Back
Top