Search code examples
c++visual-c++comatlmapi

Modify Recipients for a MAPI message



what i need to do is to backup recipients of MAPI message, and do some modification to the message (which may change the recipients also), after that i want to copy the backed up recipient back to the message again, here is the flow:

message is the MAPI IMessage object
call message->GetRecipientTable, the result is LPMAPITABLE
do changes to message
call message->ModifyRecipients, which takes LPADRLIST

my problem is that i want to take the result LPMAPITABLE and input that into ModifyRecipients, but it takes only LPADRLIST. is there a way to convert that? other than looping LPMAPITABLE and copying one by one?


Solution

  • Use IMAPITable::QueryRows. Or HrQueryAllRows (which wraps IMAPITable::SetColumns/Restrict/QueryRows in a single call). SRowSet can be cast to AdrList - they have the same memory layout.