A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How to specify the "current entry id" to GetItemFromID?



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 26th 09, 03:18 AM posted to microsoft.public.outlook.program_addins
ryotyankou via OfficeKB.com
external usenet poster
 
Posts: 101
Default How to specify the "current entry id" to GetItemFromID?

Hi, Dmitry, Thank you for your help. This is not a new problem, but unsolved
one.
It's written by VC2005/ATL, an outlook plugin.
(Outlook::ApplicationEvents_11), 0x0000FAB5, OnNewMailEx
void __stdcall CXXX::OnNewMailEx(BSTR EntryId)
{
//Codes to get m_NameSpacePtr;
Outlook::_MailItemPtr NewMailItem = m_NameSpacePtr-GetItemFromID(_bstr_t
(EntryId));
}
Can this code get all current entryid? If the income e-mail is not encrypted,
the GetItemFromID can get _MailItemPtr normally. Or it will return NULL. As
you mentioned, "Are you sure you specify the right entry id? Do you get an
error? I don't think GetItemFromID can ever return null rather
than raise an exception. " But here the EntryId is pass in by Outlook, and
never be changed, What should i do with the pass-in paramater EntryId, is
there a way to make it 'current' and then pass to GetItemFromID to get the
_MailItemPtr even it is encrypted Mail item??

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...ddins/200902/1

Ads
  #2  
Old February 26th 09, 04:57 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default How to specify the "current entry id" to GetItemFromID?

I am not sure what you mean by "current entry id".
What are you trying to solve? Null being retruned from GetItemFromID?
Did you try to declare NewMailItem as a generic IDispatch in case you have
something other than MailItem?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"ryotyankou via OfficeKB.com" u48591@uwe wrote in message
news:9243b14874627@uwe...
Hi, Dmitry, Thank you for your help. This is not a new problem, but
unsolved
one.
It's written by VC2005/ATL, an outlook plugin.
(Outlook::ApplicationEvents_11), 0x0000FAB5, OnNewMailEx
void __stdcall CXXX::OnNewMailEx(BSTR EntryId)
{
//Codes to get m_NameSpacePtr;
Outlook::_MailItemPtr NewMailItem =
m_NameSpacePtr-GetItemFromID(_bstr_t
(EntryId));
}
Can this code get all current entryid? If the income e-mail is not
encrypted,
the GetItemFromID can get _MailItemPtr normally. Or it will return NULL.
As
you mentioned, "Are you sure you specify the right entry id? Do you get an
error? I don't think GetItemFromID can ever return null rather
than raise an exception. " But here the EntryId is pass in by Outlook, and
never be changed, What should i do with the pass-in paramater EntryId, is
there a way to make it 'current' and then pass to GetItemFromID to get the
_MailItemPtr even it is encrypted Mail item??

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...ddins/200902/1



  #3  
Old February 27th 09, 02:03 AM posted to microsoft.public.outlook.program_addins
ryotyankou via OfficeKB.com
external usenet poster
 
Posts: 101
Default How to specify the "current entry id" to GetItemFromID?

I'm sorry, i typed wrong word, it is not "current" but "correct". My purpose
is just to retrieve the MailItem from the pass-in paramater (BSTR entryid).
But the GetItemFormID return NULL if e-mail's encrypted.
Yes, i tried to get a generic IDispatch from GetItemFromID, it's OK, but i
have no idea what could i do with the gotten IDispatch pointer. Again, my
purpose is to get encrypted e-mail's MailItem so that i can operate the e-
mail easily. Any ideas? TIA.


Dmitry Streblechenko wrote:
I am not sure what you mean by "current entry id".
What are you trying to solve? Null being retruned from GetItemFromID?
Did you try to declare NewMailItem as a generic IDispatch in case you have
something other than MailItem?

Hi, Dmitry, Thank you for your help. This is not a new problem, but
unsolved

[quoted text clipped - 18 lines]
there a way to make it 'current' and then pass to GetItemFromID to get the
_MailItemPtr even it is encrypted Mail item??


--
Message posted via http://www.officekb.com

  #4  
Old February 27th 09, 06:41 AM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default How to specify the "current entry id" to GetItemFromID?

Can you use late binding (IDispatch::GetIDsOfNames/Invoke) to retrieve the
Class property?
What do you see if you run the following script from Outlook Spy (click
"Script Editor" button on the OutlookSpy toolbar, paste the script, click
Run)

BrowseObject(Application.ActiveExplorer.Selection( 1))

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"ryotyankou via OfficeKB.com" u48591@uwe wrote in message
news:924f9d529567c@uwe...
I'm sorry, i typed wrong word, it is not "current" but "correct". My
purpose
is just to retrieve the MailItem from the pass-in paramater (BSTR
entryid).
But the GetItemFormID return NULL if e-mail's encrypted.
Yes, i tried to get a generic IDispatch from GetItemFromID, it's OK, but i
have no idea what could i do with the gotten IDispatch pointer. Again, my
purpose is to get encrypted e-mail's MailItem so that i can operate the e-
mail easily. Any ideas? TIA.


Dmitry Streblechenko wrote:
I am not sure what you mean by "current entry id".
What are you trying to solve? Null being retruned from GetItemFromID?
Did you try to declare NewMailItem as a generic IDispatch in case you have
something other than MailItem?

Hi, Dmitry, Thank you for your help. This is not a new problem, but
unsolved

[quoted text clipped - 18 lines]
there a way to make it 'current' and then pass to GetItemFromID to get
the
_MailItemPtr even it is encrypted Mail item??


--
Message posted via http://www.officekb.com



  #5  
Old March 2nd 09, 07:57 AM posted to microsoft.public.outlook.program_addins
ryotyankou via OfficeKB.com
external usenet poster
 
Posts: 101
Default How to specify the "current entry id" to GetItemFromID?

The result of run script is: The MailItem property page is shown. I have no
idea about the first paramater of GetIDsOfNames, i give it "_MailItem" which
i saw via OutlookSpy as its value, but return E_NOINTERFACE.
I had another try, if we can get the dispatch pointer, why not to use it to
QI the MailItem? This is the code i tried, but failed with return value
"E_NOINTERFACE", what's the wrong with my code?

Outlook::_NameSpacePtr NameSpacePtr = m_spApp-ActiveExplorer()-GetSession()
;
if(NameSpacePtr == NULL)
{
return;
}
Outlook::MAPIFolderPtr inboxFolderPtr = NameSpacePtr-GetDefaultFolder
(Outlook:lFolderInbox);
if(inboxFolderPtr == NULL)
{
return;
}
IDispatch *lpDisp = NameSpacePtr-GetItemFromID(_bstr_t(EntryId), _variant_t
(inboxFolderPtr-StoreID));
if(lpDisp == NULL)
{
return;
}

HRESULT hr = S_OK;
Outlook::_MailItemPtr spMailItem;
hr = lpDisp-QueryInterface(__uuidof(Outlook::_MailItem),(void **)&spMailItem)
;
if(SUCCEEDED(hr))//always return E_NOINTERFACE
{
//do my work here
}


Dmitry Streblechenko wrote:
Can you use late binding (IDispatch::GetIDsOfNames/Invoke) to retrieve the
Class property?
What do you see if you run the following script from Outlook Spy (click
"Script Editor" button on the OutlookSpy toolbar, paste the script, click
Run)

BrowseObject(Application.ActiveExplorer.Selection (1))

I'm sorry, i typed wrong word, it is not "current" but "correct". My
purpose

[quoted text clipped - 17 lines]
the
_MailItemPtr even it is encrypted Mail item??


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...ddins/200903/1

  #6  
Old March 3rd 09, 10:54 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default How to specify the "current entry id" to GetItemFromID?

That means the message is not a MailItem. Could be ReportItem, MeetingItem,
etc.
The first parameter in GetIDsOfNames is the name of the property, e.g.
"Class".

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"ryotyankou via OfficeKB.com" u48591@uwe wrote in message
news:92786b09727d7@uwe...
The result of run script is: The MailItem property page is shown. I have
no
idea about the first paramater of GetIDsOfNames, i give it "_MailItem"
which
i saw via OutlookSpy as its value, but return E_NOINTERFACE.
I had another try, if we can get the dispatch pointer, why not to use it
to
QI the MailItem? This is the code i tried, but failed with return value
"E_NOINTERFACE", what's the wrong with my code?

Outlook::_NameSpacePtr NameSpacePtr =
m_spApp-ActiveExplorer()-GetSession()
;
if(NameSpacePtr == NULL)
{
return;
}
Outlook::MAPIFolderPtr inboxFolderPtr = NameSpacePtr-GetDefaultFolder
(Outlook:lFolderInbox);
if(inboxFolderPtr == NULL)
{
return;
}
IDispatch *lpDisp = NameSpacePtr-GetItemFromID(_bstr_t(EntryId),
_variant_t
(inboxFolderPtr-StoreID));
if(lpDisp == NULL)
{
return;
}

HRESULT hr = S_OK;
Outlook::_MailItemPtr spMailItem;
hr =
lpDisp-QueryInterface(__uuidof(Outlook::_MailItem),(void **)&spMailItem)
;
if(SUCCEEDED(hr))//always return E_NOINTERFACE
{
//do my work here
}


Dmitry Streblechenko wrote:
Can you use late binding (IDispatch::GetIDsOfNames/Invoke) to retrieve the
Class property?
What do you see if you run the following script from Outlook Spy (click
"Script Editor" button on the OutlookSpy toolbar, paste the script, click
Run)

BrowseObject(Application.ActiveExplorer.Selectio n(1))

I'm sorry, i typed wrong word, it is not "current" but "correct". My
purpose

[quoted text clipped - 17 lines]
the
_MailItemPtr even it is encrypted Mail item??


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...ddins/200903/1



  #7  
Old March 4th 09, 01:52 AM posted to microsoft.public.outlook.program_addins
ryotyankou via OfficeKB.com
external usenet poster
 
Posts: 101
Default How to specify the "current entry id" to GetItemFromID?

No, i don't think so, i'm sure it is a MailItem, because it is my test e-mail
(It is the case, my outlook have two accounts, A and B, i Use A send an
encrypted e-mail to B, and receive this e-mail, then the plugin will enter
OnNewMailEx(BSTR entryId) function.).

I got it, i can use GetIDsOfNames to get a class property of this income item,
but i can't get MailItem, am i right?

Dmitry Streblechenko wrote:
That means the message is not a MailItem. Could be ReportItem, MeetingItem,
etc.
The first parameter in GetIDsOfNames is the name of the property, e.g.
"Class".

The result of run script is: The MailItem property page is shown. I have
no

[quoted text clipped - 50 lines]
the
_MailItemPtr even it is encrypted Mail item??


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...ddins/200903/1

  #8  
Old March 10th 09, 04:51 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default How to specify the "current entry id" to GetItemFromID?

The whole point of retrieving the value of the Class property is to make
sure trhat you really have a MailItem object.
Try the following script in OutlookSpy: click Application button on the
OutlookSpy toolbar, go to the Script tab, paste teh script below. Now
whenever a new message arrives, OutlookSpy will open a new IDispatch browser
where you shoudl be able to see all the object properties.

sub Application_NewMailEx(EntryIDCollection)
set Msg = Application.Session.GetItemfromID(EntryIDCollectio n)
BrowseObject(Msg)
end sub

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"ryotyankou via OfficeKB.com" u48591@uwe wrote in message
news:928e607f8eb42@uwe...
No, i don't think so, i'm sure it is a MailItem, because it is my test
e-mail
(It is the case, my outlook have two accounts, A and B, i Use A send an
encrypted e-mail to B, and receive this e-mail, then the plugin will enter
OnNewMailEx(BSTR entryId) function.).

I got it, i can use GetIDsOfNames to get a class property of this income
item,
but i can't get MailItem, am i right?

Dmitry Streblechenko wrote:
That means the message is not a MailItem. Could be ReportItem,
MeetingItem,
etc.
The first parameter in GetIDsOfNames is the name of the property, e.g.
"Class".

The result of run script is: The MailItem property page is shown. I have
no

[quoted text clipped - 50 lines]
the
_MailItemPtr even it is encrypted Mail item??


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...ddins/200903/1



  #9  
Old March 13th 09, 10:19 AM posted to microsoft.public.outlook.program_addins
ryotyankou via OfficeKB.com
external usenet poster
 
Posts: 101
Default How to specify the "current entry id" to GetItemFromID?

Thank you for your help so far, i change my way to process the incoming e-
mail, use IMessage interface instead of MailItem. These are the steps:
1.Use OpenEntry open the item to get IMessage interface.
2.Use IMessage interface query IMAPIProp interface, then make operation on
the item.
It works fine, Thank you again in advance, you are great people. ^_^

Dmitry Streblechenko wrote:
The whole point of retrieving the value of the Class property is to make
sure trhat you really have a MailItem object.
Try the following script in OutlookSpy: click Application button on the
OutlookSpy toolbar, go to the Script tab, paste teh script below. Now
whenever a new message arrives, OutlookSpy will open a new IDispatch browser
where you shoudl be able to see all the object properties.

sub Application_NewMailEx(EntryIDCollection)
set Msg = Application.Session.GetItemfromID(EntryIDCollectio n)
BrowseObject(Msg)
end sub

No, i don't think so, i'm sure it is a MailItem, because it is my test
e-mail

[quoted text clipped - 17 lines]
the
_MailItemPtr even it is encrypted Mail item??


--
Message posted via http://www.officekb.com

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Outlook tasks "current view" as a calendar option Wright Outlook - Using Forms 6 April 5th 07 06:31 PM
Journal "Start Date" and "Entry Created Date" joemce Outlook - Using Contacts 0 August 1st 06 07:33 PM
Outlook Multi-email acct should default "From address" to current SB Outlook - Installation 7 July 31st 06 05:57 PM
Explain Journal entry vs. "Notes" section on Contact "Box" Charles Dice Outlook - Using Contacts 1 July 11th 06 03:50 PM
open "new appointment" at current time for incidental meeting etc Bill! Outlook - Calandaring 1 May 16th 06 12:26 PM


All times are GMT +1. The time now is 08:43 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.