Problem with Outlook security dialog

K

kistvan

Hi,

I have an Outlook add-in which should perform some operations with the email
addresses ( recipients ) from a sent email.
When the OnNewMail function is triggered I call the
spMailItem->get_Recipients(&spRecipients); method. When this method is
called the Outlook security dialog appears.
In other parts of the add-in I used Extended MAPI to avoid the security
dialogs: I read the entry ID from the mail item, called the OpenEntry
function and after that I read the email address from the return IMessage
object. When a mail is sent and the NewMail action is triggered the mail
item doesn't have an entry ID, so I cannot use Extended MAPI further.
How can I avoid this dialog ? This happens only when I use Outlook XP; if I
use Outlook 2003 the security dialogs don't appears.

Thanks
 
D

Dmitry Streblechenko \(MVP\)

You don't need to call IMAPISession::OpenEntry: simply read the MAPIOBJECT
property and QI it for IMessage Extended MAPI interface.

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

kistvan

I tried this way but without success, when I try to get the properties with the GetProps function, this fails:
Below is the code snippet, is there something wrong ?

IUnknown* pUnk = NULL;
IMessage* pIMessage = NULL;

spMailItem->get_MAPIOBJECT( &pUnk );
hr = pUnk->QueryInterface(IID_IMessage, (void**) &pIMessage); // succeeds hr = 0

if(pIMessage)
{
ULONG uMsgProps = 0L;
SPropValue *msgProps = NULL;
LPBYTE lpSenderEid = NULL;
ULONG cbSenderEid = 0L;

SizedSPropTagArray( 4, msgPropTag) =
{
4,
{
PR_SENDER_ENTRYID,
PR_SENDER_ADDRTYPE,
PR_SENDER_EMAIL_ADDRESS,
PR_SENDER_NAME
}
};

hr = pIMessage->GetProps( (SPropTagArray*)&msgPropTag, 0, &uMsgProps, &msgProps ); // fails hr = MAPI_W_ERRORS_RETURNED

// get the entry id info
if ( msgProps[0].ulPropTag == PR_SENDER_ENTRYID) // cannot retrieve this property
{ ............. }
if ( msgProps[1].ulPropTag == PR_SENDER_ADDRTYPE) // cannot retrieve this property
{ ..............}
if ( msgProps[2].ulPropTag == PR_SENDER_EMAIL_ADDRESS) // cannot retrieve this property
{ ................}
if ( msgProps[3].ulPropTag == PR_SENDER_NAME) // cannot retrieve this property
{................}
}
if ( pIMessage )
{
pIMessage->Release();
}

Thanks
 
D

Dmitry Streblechenko \(MVP\)

When is this code called?

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

I tried this way but without success, when I try to get the properties with
the GetProps function, this fails:
Below is the code snippet, is there something wrong ?

IUnknown* pUnk = NULL;
IMessage* pIMessage = NULL;

spMailItem->get_MAPIOBJECT( &pUnk );
hr = pUnk->QueryInterface(IID_IMessage, (void**) &pIMessage); // succeeds
hr = 0

if(pIMessage)
{
ULONG uMsgProps = 0L;
SPropValue *msgProps = NULL;
LPBYTE lpSenderEid = NULL;
ULONG cbSenderEid = 0L;

SizedSPropTagArray( 4, msgPropTag) =
{
4,
{
PR_SENDER_ENTRYID,
PR_SENDER_ADDRTYPE,
PR_SENDER_EMAIL_ADDRESS,
PR_SENDER_NAME
}
};

hr = pIMessage->GetProps( (SPropTagArray*)&msgPropTag, 0, &uMsgProps,
&msgProps ); // fails hr = MAPI_W_ERRORS_RETURNED

// get the entry id info
if ( msgProps[0].ulPropTag == PR_SENDER_ENTRYID) // cannot
retrieve this property
{ ............. }
if ( msgProps[1].ulPropTag == PR_SENDER_ADDRTYPE) // cannot retrieve
this property
{ ..............}
if ( msgProps[2].ulPropTag == PR_SENDER_EMAIL_ADDRESS) // cannot
retrieve this property
{ ................}
if ( msgProps[3].ulPropTag == PR_SENDER_NAME) // cannot retrieve this
property
{................}
}
if ( pIMessage )
{
pIMessage->Release();
}

Thanks
 

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