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 change recipients of a received message?



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 1st 09, 11:20 PM posted to microsoft.public.outlook.program_addins
ryotyankou
external usenet poster
 
Posts: 4
Default How to change recipients of a received message?

My is ATL/VC2005. OnNewEmail to dispatch the event.
While OnNewEmail function were invoked, I tried the two methods:
1. ");
2. Get IMessage interface, then call SetProps() function with Tag
PR_DISPLAY_TO_A, return value's S_OK. But when i open the message, nothing
were changed.
What should i do then?
Ads
  #2  
Old February 2nd 09, 08:00 AM posted to microsoft.public.outlook.program_addins
ryotyankou via OfficeKB.com
external usenet poster
 
Posts: 101
Default How to change recipients of a received message?

And i tried the IMessage::ModifyRecipients(XXX_ADD), it still couldn't work.
And i modified the message header's "to:" field, it seems that no effect to
the message itself at all. Could someone help?

ryotyankou wrote:
My is ATL/VC2005. OnNewEmail to dispatch the event.
While OnNewEmail function were invoked, I tried the two methods:
1. ");
2. Get IMessage interface, then call SetProps() function with Tag
PR_DISPLAY_TO_A, return value's S_OK. But when i open the message, nothing
were changed.
What should i do then?


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

  #3  
Old February 2nd 09, 04:52 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default How to change recipients of a received message?

PR_DISPLAY_TO is not settable.
NewMail event (unlike NewMailEx) does not pass the new message as a
parameter. How do you retrieve the new message?
Do you save the message?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"ryotyankou" u48591@uwe wrote in message news:910cacbf18233@uwe...
My is ATL/VC2005. OnNewEmail to dispatch the event.
While OnNewEmail function were invoked, I tried the two methods:
1. ");
2. Get IMessage interface, then call SetProps() function with Tag
PR_DISPLAY_TO_A, return value's S_OK. But when i open the message, nothing
were changed.
What should i do then?



  #4  
Old February 3rd 09, 02:00 AM posted to microsoft.public.outlook.program_addins
ryotyankou via OfficeKB.com
external usenet poster
 
Posts: 101
Default How to change recipients of a received message?

Not NewMailEx(BSTR xxx), what i processed is Outlook::ItemsEvents OnItemAdd
(LPDISPATCH).
With the income MailItem, How to add some other recipients to it? I tried the
following code, but couldn't work:
IUnknownPtr pUnkSession = MailItem-GetSession()-GetMAPIOBJECT();
if(pUnkSession == NULL)
return E_FAIL;

IUnknownPtr pUnkMsg = MailItem-GetMAPIOBJECT();
if(pUnkMsg == NULL)
return E_FAIL;

IMAPISession * pSession;
if(FAILED(pUnkSession-QueryInterface(IID_IMAPISession, (void**)&pSession)))
{
return E_FAIL;
}

IMessage *pMessage = NULL;
if(FAILED(pUnkMsg-QueryInterface(IID_IMessage, (void**)&pMessage)))
{
pSession-Release();
return E_FAIL;
}

//test only
int nBufSize = CbNewADRLIST(1);
LPADRLIST pAddressList=NULL;
MAPIAllocateBuffer(nBufSize,(LPVOID FAR*)&pAddressList);
memset(pAddressList,0,nBufSize);

const int nProperties=2;
pAddressList-cEntries=1;

pAddressList-aEntries[0].ulReserved1=0;
pAddressList-aEntries[0].cValues=nProperties;

MAPIAllocateBuffer(sizeof(SPropValue)*nProperties, (LPVOID FAR*)&pAddressList-
aEntries[0].rgPropVals);

memset(pAddressList-aEntries[0].rgPropVals, 0, sizeof(SPropValue)
*nProperties);

pAddressList-aEntries[0].rgPropVals[0].ulPropTag=PR_RECIPIENT_TYPE;
pAddressList-aEntries[0].rgPropVals[0].Value.ul=MAPI_TO;

CString ");
pAddressList-aEntries[0].rgPropVals[1].ulPropTag=PR_DISPLAY_NAME;
pAddressList-aEntries[0].rgPropVals[1].Value.lpszA=(LPSTR)temp.GetString();

// IAddrBook * pAddrBook = NULL;
// if(FAILED(pSession-OpenAddressBook(0, NULL, AB_NO_DIALOG, &pAddrBook)))
// {
// pSession-Release();
// pMessage-Release();
// FreePadrlist(pAddressList);
// return E_FAIL;
// }

// if(FAILED(pAddrBook-ResolveName(0, cm_nMAPICode, NULL, pAddressList)))
// {
// pSession-Release();
// pMessage-Release();
// FreePadrlist(pAddressList);
// pAddrBook-Release();
// return E_FAIL;
// }

if(FAILED(pMessage-ModifyRecipients(MODRECIP_ADD, pAddressList)))
{
pSession-Release();
pMessage-Release();
FreePadrlist(pAddressList);
// pAddrBook-Release();
return E_FAIL;
}

FreePadrlist(pAddressList);
pMessage-Release();
// pAddrBook-Release();
pSession-Release();

Dmitry Streblechenko wrote:
PR_DISPLAY_TO is not settable.
NewMail event (unlike NewMailEx) does not pass the new message as a
parameter. How do you retrieve the new message?
Do you save the message?

My is ATL/VC2005. OnNewEmail to dispatch the event.
While OnNewEmail function were invoked, I tried the two methods:

[quoted text clipped - 3 lines]
were changed.
What should i do then?


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

  #5  
Old February 3rd 09, 10:10 AM posted to microsoft.public.outlook.program_addins
ryotyankou via OfficeKB.com
external usenet poster
 
Posts: 101
Default How to change recipients of a received message?

Hi, Dmitry, I checked my code and found that my process is not cogitate(Use
OnItemAdd, not OnNewMailEx), if the MailItem's encrypted, the add-in will do
nothing. Can i convert the entryid(OnNewEmailEx) to MailItem? How could i get
IMessage from entryid? Thanks a lot.

Dmitry Streblechenko wrote:
PR_DISPLAY_TO is not settable.
NewMail event (unlike NewMailEx) does not pass the new message as a
parameter. How do you retrieve the new message?
Do you save the message?

My is ATL/VC2005. OnNewEmail to dispatch the event.
While OnNewEmail function were invoked, I tried the two methods:

[quoted text clipped - 3 lines]
were changed.
What should i do then?


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

  #6  
Old February 3rd 09, 10:42 AM posted to microsoft.public.outlook.program_addins
ryotyankou via OfficeKB.com
external usenet poster
 
Posts: 101
Default How to change recipients of a received message?

void __stdcall CPlug1::OnNewMailEx(BSTR EntryId)
{
Outlook::_NameSpacePtr m_NameSpacePtr = m_spApp-ActiveExplorer()-
GetSession();

if(m_NameSpacePtr == NULL)
{
return;
}
Outlook::_MailItemPtr MailItem = m_NameSpacePtr-GetItemFromID(_bstr_t
(EntryId));
//do other things
}
The code can work with most of the case but encrypted MailItem, again, What
should i do then?

PR_DISPLAY_TO is not settable.
NewMail event (unlike NewMailEx) does not pass the new message as a

[quoted text clipped - 6 lines]
were changed.
What should i do then?


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

  #7  
Old February 3rd 09, 04:52 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default How to change recipients of a received message?

You never save the message

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"ryotyankou via OfficeKB.com" u48591@uwe wrote in message
news:9121d684e7a85@uwe...
Not NewMailEx(BSTR xxx), what i processed is Outlook::ItemsEvents
OnItemAdd
(LPDISPATCH).
With the income MailItem, How to add some other recipients to it? I tried
the
following code, but couldn't work:
IUnknownPtr pUnkSession = MailItem-GetSession()-GetMAPIOBJECT();
if(pUnkSession == NULL)
return E_FAIL;

IUnknownPtr pUnkMsg = MailItem-GetMAPIOBJECT();
if(pUnkMsg == NULL)
return E_FAIL;

IMAPISession * pSession;
if(FAILED(pUnkSession-QueryInterface(IID_IMAPISession,
(void**)&pSession)))
{
return E_FAIL;
}

IMessage *pMessage = NULL;
if(FAILED(pUnkMsg-QueryInterface(IID_IMessage, (void**)&pMessage)))
{
pSession-Release();
return E_FAIL;
}

//test only
int nBufSize = CbNewADRLIST(1);
LPADRLIST pAddressList=NULL;
MAPIAllocateBuffer(nBufSize,(LPVOID FAR*)&pAddressList);
memset(pAddressList,0,nBufSize);

const int nProperties=2;
pAddressList-cEntries=1;

pAddressList-aEntries[0].ulReserved1=0;
pAddressList-aEntries[0].cValues=nProperties;

MAPIAllocateBuffer(sizeof(SPropValue)*nProperties, (LPVOID
FAR*)&pAddressList-
aEntries[0].rgPropVals);

memset(pAddressList-aEntries[0].rgPropVals, 0, sizeof(SPropValue)
*nProperties);

pAddressList-aEntries[0].rgPropVals[0].ulPropTag=PR_RECIPIENT_TYPE;
pAddressList-aEntries[0].rgPropVals[0].Value.ul=MAPI_TO;

CString ");
pAddressList-aEntries[0].rgPropVals[1].ulPropTag=PR_DISPLAY_NAME;
pAddressList-aEntries[0].rgPropVals[1].Value.lpszA=(LPSTR)temp.GetString();

// IAddrBook * pAddrBook = NULL;
// if(FAILED(pSession-OpenAddressBook(0, NULL, AB_NO_DIALOG,
&pAddrBook)))
// {
// pSession-Release();
// pMessage-Release();
// FreePadrlist(pAddressList);
// return E_FAIL;
// }

// if(FAILED(pAddrBook-ResolveName(0, cm_nMAPICode, NULL, pAddressList)))
// {
// pSession-Release();
// pMessage-Release();
// FreePadrlist(pAddressList);
// pAddrBook-Release();
// return E_FAIL;
// }

if(FAILED(pMessage-ModifyRecipients(MODRECIP_ADD, pAddressList)))
{
pSession-Release();
pMessage-Release();
FreePadrlist(pAddressList);
// pAddrBook-Release();
return E_FAIL;
}

FreePadrlist(pAddressList);
pMessage-Release();
// pAddrBook-Release();
pSession-Release();

Dmitry Streblechenko wrote:
PR_DISPLAY_TO is not settable.
NewMail event (unlike NewMailEx) does not pass the new message as a
parameter. How do you retrieve the new message?
Do you save the message?

My is ATL/VC2005. OnNewEmail to dispatch the event.
While OnNewEmail function were invoked, I tried the two methods:

[quoted text clipped - 3 lines]
were changed.
What should i do then?


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



  #8  
Old February 3rd 09, 04:53 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default How to change recipients of a received message?

So what happens when you process an encrypted message?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"ryotyankou via OfficeKB.com" u48591@uwe wrote in message
news:91266404399eb@uwe...
void __stdcall CPlug1::OnNewMailEx(BSTR EntryId)
{
Outlook::_NameSpacePtr m_NameSpacePtr = m_spApp-ActiveExplorer()-
GetSession();

if(m_NameSpacePtr == NULL)
{
return;
}
Outlook::_MailItemPtr MailItem = m_NameSpacePtr-GetItemFromID(_bstr_t
(EntryId));
//do other things
}
The code can work with most of the case but encrypted MailItem, again,
What
should i do then?

PR_DISPLAY_TO is not settable.
NewMail event (unlike NewMailEx) does not pass the new message as a

[quoted text clipped - 6 lines]
were changed.
What should i do then?


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



  #9  
Old February 4th 09, 01:52 AM posted to microsoft.public.outlook.program_addins
ryotyankou via OfficeKB.com
external usenet poster
 
Posts: 101
Default How to change recipients of a received message?

Outlook::_MailItemPtr MailItem = m_NameSpacePtr-GetItemFromID(_bstr_t
(EntryId));
If the message's encrypted, the MailItem is NULL, otherwise, it is ok.

Dmitry Streblechenko wrote:
So what happens when you process an encrypted message?

void __stdcall CPlug1::OnNewMailEx(BSTR EntryId)
{

[quoted text clipped - 17 lines]
were changed.
What should i do then?


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

  #10  
Old February 4th 09, 04:46 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default How to change recipients of a received message?

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.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"ryotyankou via OfficeKB.com" u48591@uwe wrote in message
news:912e584d7246d@uwe...
Outlook::_MailItemPtr MailItem = m_NameSpacePtr-GetItemFromID(_bstr_t
(EntryId));
If the message's encrypted, the MailItem is NULL, otherwise, it is ok.

Dmitry Streblechenko wrote:
So what happens when you process an encrypted message?

void __stdcall CPlug1::OnNewMailEx(BSTR EntryId)
{

[quoted text clipped - 17 lines]
were changed.
What should i do then?


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



 




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
Can't change text size in received mail Robert Outlook Express 10 October 23rd 07 01:38 PM
prevent e-mail message recipients automatically forward a message IH Outlook - Using Forms 3 November 1st 06 09:00 PM
How do i change the sent time to received time in outlook message? Freedom Outlook - General Queries 1 August 1st 06 02:42 PM
I don't want the recipients to reply my message Chi Outlook - General Queries 1 March 29th 06 04:40 PM
Custom meeting form - action on change of recipients jondxs Outlook - Using Forms 2 March 14th 06 02:24 PM


All times are GMT +1. The time now is 09:22 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.