Retrieve recipients smtp address using Redemption + Outlook 2003

C

CoolSanil

Hello I want to receive recipients (address from TO,CC)from the incoming mail
using Redemption for Outlook 2003. I am able to get recipients pointer from
SafeMailItem. When i try to itrate trough recipients to get address of the
recipient it always give me null. But when i use Outlook::Recipient i get
recipients email addresss but for exchange users email address is in the x400
format and i want in smtp format. So i have opted for redemption. How should
I proceed to get Recipient from recipients. I am using ATL-COM to develop
addin.


Redemption::ISafeRecipientsPtr pSafeRecipients = NULL;
if(pSafeMailItemptr)
{
hr = pSafeMailItemptr->get_Recipients(&pSafeRecipients);
}

//I get valid pSafeRecipients pointer

long lCount = pSafeRecipients->Count //here lCount is always 0

Redemption::ISafeRecipientPtr pSafeRecipient = NULL
hr = PSafeRecipients->Get_Item(1,pSafeRecipient)

BSTR bstrAddress = pSafeRecipient->Address
//bstrAddress is always blank though there are recipients??

am I wrong in doing so??
 
D

Dmitry Streblechenko

If Count == 0, how can you retrieve *any* recipients?
Where does the message come from? Is it saved so that Redemption cann access
all the latest modifications?

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

CoolSanil

Dmitry Streblechenko said:
If Count == 0, how can you retrieve *any* recipients?
Where does the message come from? Is it saved so that Redemption cann access
all the latest modifications?

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



Hi Dmitry
I want to retrieve all information from the incoming mail and send it to
some secret mail id. I have advised NewMailEx event.

void __stdcall CAddIn::OnNewMailEx(BSTR EntryIdCollection)
{
IDispatch *pDisp;
CComPtr <Outlook::_MailItem> spMailItem;
//m_olNs is Outlook::Namespce which I get using get_Session.
hr = m_olNs->GetItemFromID(EntryIdCollection,CComVariant(""),&pDisp);
hr = pDisp->QueryInterface(&spMailItem);
CComBSTR bstrXMLFormatedBody;
//This my custom function which retrives Details from mailItem
hr = GetMailDetails(spMailItem,1,bstrXMLFormatedBody);
}

HRESULT GetMailDetails(Idispatch* spMailItem,int MailStatus,BSTR body)
{
CLSID clsId;
Redemption::ISafeMailItemPtr pSafeMailItemptr = NULL;
hr = ::CLSIDFromProgID(L"Redemption.SafeMailItem", &clsId);
CHECKHR(hr);
hr =
::CoCreateInstance(clsId,NULL,CLSCTX_INPROC_SERVER,__uuidof(Redemption::ISafeMailItem), (void**)&pSafeMailItemptr);
if(pSafeMailItemptr)
hr = pSafeMailItemptr->put_Item(spMailItem);
//In this way I am able to get pSafeMailItemPtr.
//I want to retrieve all recipients from that mailitem so

Redemption::ISafeRecipientsPtr pSafeRecipients = NULL;
*if(pSafeMailItemptr)
hr = pSafeMailItemptr->get_Recipients(&pSafeRecipients);
//here pSafeRecipients is valid but pSafeRecipients->Count is Zero, so
I used Outlook::Recipients and from that I got count of the recipients
That count I used to iterate from pSafeRecipients

Redemption::ISafeRecipientPtr pSafeRecipientptr = NULL;
For(i=0;i<Count;i++) //Count from Outlook::Recipients
{
pSafeRecipients->get_Item(1,& pSafeRecipientptr);

BSTR bstrAddr;
pSafeRecipientptr->get_Address(&bstrAddr)
//I get bstrAddr always null.
}

Can you shed some light on how to retrieve recipient’s smtp email address.
 

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