Access to MailItem properties before opening new inspector ?

  • Thread starter Thread starter Marcin
  • Start date Start date
M

Marcin

Hi,

when opening MailItem in a new inspector, certain properties are lost
(SenderEmailAddress for example). I can access those properties before, in
SelectionChange, ItemLoad or Read events, however, that works fine for items
that have not been loaded into memory / cached yet.
If the item had been however read, it is somehow simply loaded from
cache/memory, without triggering those events. Any idea on accessing this
particular cached object properties before opening new inspector or forcing
flushing the cache to cause re-reading ?
 
Properties in an item are not lost when you open that item in an Inspector,
why would you say that?

Are you trying to get the properties in the NewInspector event handler? Wait
until the first Activate event for that Inspector, when the object for
Inspector.CurrentItem isn't a weak object reference but is fully filled in.
 
Ken,

when replying or forwarding an email, I am trying to get original sender
amongst other (also some from Item.Properties). However, the sender is null,
which is probably due to the fact, that the reply is de facto a new email
(new MailItem object). What I need , is access to the original email (that I
am replying to or forwarding), so that I could read some stuff from it. As
already said - I can get it from SelectionChange,Read or ItemLoad events, but
only when reading new item (new -> that does not exist in the Outlook cache
yet).
To make it short - when executing action like reply or forward on MailItem,
I need to access the original message.

Kind regards

marcin
 
Thanks a lot,Sue, will have a look at this immediatelly.

By the way - do you happen to have any references on Outlook caching and
cache access/manipulation from API ?

Kind regards

marcin
 
What cache are you referring to? I can think of at least three different contexts in which "cache" would be relevant. Please start a new topic thread with more details.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
There must be some kind of caching, I don't exactly know what kind of, but in
fact, I would like to prevent caching at all :-), or get possibility of
reading items from cache before they are displayed in inspectors or explorers.

Anyway, thanks a lot for You hint on ConversationTopic. I started playing
with it, however, experienced a small problem using
Application.AdvancedSearch :
string filter = "[ConversationTopic] = '" + Item.ConversationTopic + "'" ;
try
{
StringBuilder SearchScope = new StringBuilder("'" +
Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail).FolderPath + "'");
SearchScope.Append(",'" +
Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox).FolderPath + "'");
SearchScope.Append(",'" +
Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems).FolderPath + "'");
//exception is caught on line below - "The operation failed."
Outlook.Search SearchPotentialParents =
Application.AdvancedSearch(SearchScope.ToString(), filter, true,
ThisAddIn.AdvancedParentSearchTag);
}

Any idea why would it fail ? The error message is not really meaningful :-(

kind regards

marcin
 
You're using the Find/Restrict format for the search filter string, but AdvancedSearch requires the DASL syntax; see http://www.outlookcode.com/news.aspx?id=30.

Also, if you're searching only default folders, I don't think you need the full path in the scope string, so a string like this should work:

"'Sent Items','Inbox', 'Deleted Items'"

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


Marcin said:
There must be some kind of caching, I don't exactly know what kind of, but in
fact, I would like to prevent caching at all :-), or get possibility of
reading items from cache before they are displayed in inspectors or explorers.

Anyway, thanks a lot for You hint on ConversationTopic. I started playing
with it, however, experienced a small problem using
Application.AdvancedSearch :
string filter = "[ConversationTopic] = '" + Item.ConversationTopic + "'" ;
try
{
StringBuilder SearchScope = new StringBuilder("'" +
Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail).FolderPath + "'");
SearchScope.Append(",'" +
Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox).FolderPath + "'");
SearchScope.Append(",'" +
Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems).FolderPath + "'");
//exception is caught on line below - "The operation failed."
Outlook.Search SearchPotentialParents =
Application.AdvancedSearch(SearchScope.ToString(), filter, true,
ThisAddIn.AdvancedParentSearchTag);
}

Any idea why would it fail ? The error message is not really meaningful :-(

kind regards

marcin

Sue Mosher said:
What cache are you referring to? I can think of at least three different contexts in which "cache" would be relevant. Please start a new topic thread with more details.
 
Marcin,

As an alternative to searching you could hook the Item's Forward, Reply and
Reply All events. By hooking these events you can take control of creation
of the forward/reply message and can copy data from the original message to
the new message. This approach requires a little more coding because you'll
need to process the Explorer's Selection event. Since users can run multiple
instances of Outlook, you'll also need to keep track of which items you've
already hooked. If you don't, you'll end up with multiple calls to your
event handler.


You're using the Find/Restrict format for the search filter string, but
AdvancedSearch requires the DASL syntax; see
http://www.outlookcode.com/news.aspx?id=30.

Also, if you're searching only default folders, I don't think you need the
full path in the scope string, so a string like this should work:

"'Sent Items','Inbox', 'Deleted Items'"

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


Marcin said:
There must be some kind of caching, I don't exactly know what kind of, but
in
fact, I would like to prevent caching at all :-), or get possibility of
reading items from cache before they are displayed in inspectors or
explorers.

Anyway, thanks a lot for You hint on ConversationTopic. I started playing
with it, however, experienced a small problem using
Application.AdvancedSearch :
string filter = "[ConversationTopic] = '" + Item.ConversationTopic + "'" ;
try
{
StringBuilder SearchScope = new StringBuilder("'" +
Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail).FolderPath
+ "'");
SearchScope.Append(",'" +
Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox).FolderPath
+ "'");
SearchScope.Append(",'" +
Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems).FolderPath
+ "'");
//exception is caught on line below - "The operation failed."
Outlook.Search SearchPotentialParents =
Application.AdvancedSearch(SearchScope.ToString(), filter, true,
ThisAddIn.AdvancedParentSearchTag);
}

Any idea why would it fail ? The error message is not really meaningful
:-(

kind regards

marcin

Sue Mosher said:
What cache are you referring to? I can think of at least three different
contexts in which "cache" would be relevant. Please start a new topic
thread with more details.
 
Back
Top