Why DispEventAdvise couldn't work?

  • Thread starter ryotyankou via OfficeKB.com
  • Start date
R

ryotyankou via OfficeKB.com

Q1: In OnConnection function, the follow code can work. I'm using outlook2003.

Outlook::MAPIFolderPtr pSentFd = m_NSPtr->GetDefaultFolder(Outlook::
olFolderSentMail);
pSentFdItems = pSentFd->GetItems();
ItemsItemAddEvent::DispEventAdvise(pSentFdItems);
But following couldn't, why?
m_NSPtr->GetFolders(); then loop to search the specified folder, i'm sure i
found the correct folder, then
if(HotPtr != NULL)//HotPtr is the correct MAPIFolderPtr for olFolderSentMail.
{
CComPtr<Outlook::_Items> HotInboxItems = HotPtr->GetItems();
long ll = HotInboxItems->GetCount();
ItemsItemAddEvent::DispEventAdvise(HotInboxItems);
}
But the event could not be fired.
Q2: How could i get MailItem of the mail receive from HTTP hotmail? I don't
know how to DispEventAdvise on hotmail's message store(I add a HTTP account
which is MS's hotmail), i use the code above to set event on the folder of
hotmail(and i'm sure the folder is correct folder), but couldn't work. Is
there a way to get hotmail's(INTERSTOR) "Namespace" so that i can get its
folder to set the current advise?
In a word, i want to get the MailItem of HTTP mail from hotmail to process,
is that clear?
 
D

Dmitry Streblechenko

1. The object raising the events (HotInboxItems) must be alive at all times.
Make sit a global/cklass variable rather than a local one.
2. There is nothing special about the Hotmail store (which is really a PST
store).

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

ryotyankou via OfficeKB.com

Yes, that's right, i change the object to a member of class, it is ok. Thanks
in advance. ^_^
But here is another question, in my test code, i assume that the MsgStore's
name is "hotmail", but in fact the name can be not "hotmail". What's the
better way to get the correct entry id of inbox?(not default MsgStore).
 
D

Dmitry Streblechenko

2. I don't think there is anything you can do if you are using the Outlook
Object Model alone.

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

ryotyankou via OfficeKB.com

Hi, Dmitry, thank you for your reply.
I am now try to use MAPI for this problem, and have a small question.
Assume the default profile name's "MyProfile". These are what i did:
1.IProfAdmin::AdminServices to get ServiceAdmin
2.IMsgServiceAdmin::GetMsgServiceTable to get table
3.IMAPITable::QueryRows to get all message store rows.
4.for loop to find property of PR_SERVICE_NAME_A use PpropFindProp.
If find check if it is "INTERSTOR", if it is "INTERSTOR", check the ""
propery, but the second check is failed, can you help me out with it?
This is the code snippet:
for(ULONG uLoop = 0; uLoop < pStoreRows->cRows; uLoop ++)
{
lpCurProp = pStoreRows->aRow[uLoop].lpProps;
uCurValue = pStoreRows->aRow[uLoop].cValues;
lpRetStoreProp = PpropFindProp( lpCurProp, uCurValue, PR_SERVICE_NAME_A )
;
if (_CheckStringProp(lpRetStoreProp, PT_STRING8))
{
// compare the string with "INTERSTOR"
CString szServiceName(lpRetStoreProp->Value.lpszA);
if(!szServiceName.CompareNoCase("INTERSTOR"))
{
lpCurProp = pStoreRows->aRow[uLoop].lpProps;
uCurValue = pStoreRows->aRow[uLoop].cValues;
// get the message provider UID
lpRetStoreProp = PpropFindProp( lpCurProp, uCurValue,
PR_PROVIDER_UID );
if(lpRetStoreProp && PR_PROVIDER_UID == lpRetStoreProp->ulPropTag)

{// Here failed, what's going on?
}
}
}
}
I'm sure that PR_PROVIDER_UID is the exist property.
Thanks in advance.

Dmitry said:
2. I don't think there is anything you can do if you are using the Outlook
Object Model alone.
Yes, that's right, i change the object to a member of class, it is ok.
Thanks
[quoted text clipped - 9 lines]
 
D

Dmitry Streblechenko

Why exactly does the check fail?
What do you see in OutlookSpy when you click IMAPISession::AdminServices

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
ryotyankou via OfficeKB.com said:
Hi, Dmitry, thank you for your reply.
I am now try to use MAPI for this problem, and have a small question.
Assume the default profile name's "MyProfile". These are what i did:
1.IProfAdmin::AdminServices to get ServiceAdmin
2.IMsgServiceAdmin::GetMsgServiceTable to get table
3.IMAPITable::QueryRows to get all message store rows.
4.for loop to find property of PR_SERVICE_NAME_A use PpropFindProp.
If find check if it is "INTERSTOR", if it is "INTERSTOR", check the ""
propery, but the second check is failed, can you help me out with it?
This is the code snippet:
for(ULONG uLoop = 0; uLoop < pStoreRows->cRows; uLoop ++)
{
lpCurProp = pStoreRows->aRow[uLoop].lpProps;
uCurValue = pStoreRows->aRow[uLoop].cValues;
lpRetStoreProp = PpropFindProp( lpCurProp, uCurValue,
PR_SERVICE_NAME_A )
;
if (_CheckStringProp(lpRetStoreProp, PT_STRING8))
{
// compare the string with "INTERSTOR"
CString szServiceName(lpRetStoreProp->Value.lpszA);
if(!szServiceName.CompareNoCase("INTERSTOR"))
{
lpCurProp = pStoreRows->aRow[uLoop].lpProps;
uCurValue = pStoreRows->aRow[uLoop].cValues;
// get the message provider UID
lpRetStoreProp = PpropFindProp( lpCurProp, uCurValue,
PR_PROVIDER_UID );
if(lpRetStoreProp && PR_PROVIDER_UID ==
lpRetStoreProp->ulPropTag)

{// Here failed, what's going on?
}
}
}
}
I'm sure that PR_PROVIDER_UID is the exist property.
Thanks in advance.

Dmitry said:
2. I don't think there is anything you can do if you are using the Outlook
Object Model alone.
Yes, that's right, i change the object to a member of class, it is ok.
Thanks
[quoted text clipped - 9 lines]
2. There is nothing special about the Hotmail store (which is really a
PST
store).
 
R

ryotyankou via OfficeKB.com

I solved it, After check the terms with outlookspy, my mind's clear and then
the problem were sloved, thank again, Dmitry.

Dmitry said:
Why exactly does the check fail?
What do you see in OutlookSpy when you click IMAPISession::AdminServices
Hi, Dmitry, thank you for your reply.
I am now try to use MAPI for this problem, and have a small question.
[quoted text clipped - 44 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top