rendered paste bodyvoid
mapi_set_recipient_table (mapi_object_t *obj_message , const char *to, const char *cc, const char *bcc)
{
struct SPropTagArray *SPropTagArray;
struct SPropValue SPropValue;
struct SRowSet *SRowSet = NULL;
TALLOC_CTX *mem_ctx;
struct FlagList *flaglist = NULL;
enum MAPISTATUS retval;
char **usernames = NULL;
char **usernames_to;
char **usernames_cc;
char **usernames_bcc;
uint32_t index = 0;
mem_ctx = talloc_init("mapi_recpient_table");
/* message->ModifyRecipients() */
SPropTagArray = set_SPropTagArray(mem_ctx, 0x6,
PR_OBJECT_TYPE,
PR_DISPLAY_TYPE,
PR_7BIT_DISPLAY_NAME,
PR_DISPLAY_NAME,
PR_SMTP_ADDRESS,
PR_GIVEN_NAME);
/* fixme: fill with cc comma sep content.
usernames += strplit(headers->cc, ',');
*/
//Recipient table
usernames_to = mapi_get_cmdline_recipients(mem_ctx, to);
usernames_cc = mapi_get_cmdline_recipients(mem_ctx, cc);
usernames_bcc = mapi_get_cmdline_recipients(mem_ctx, bcc);
usernames = mapi_collapse_recipients(mem_ctx, usernames_to, usernames_cc, usernames_bcc);
retval = ResolveNames((const char **)usernames, SPropTagArray, &SRowSet, &flaglist, 0);
mapi_errstr("ResolveNames", GetLastError());
if (retval != MAPI_E_SUCCESS) {
mapi_errstr(__PRETTY_FUNCTION__, GetLastError());
UNLOCK ();
return FALSE;
}
if (!SRowSet)
SRowSet = talloc_zero(mem_ctx, struct SRowSet);
mapi_set_usernames_RecipientType(&index, SRowSet, usernames_to, flaglist, MAPI_TO);
mapi_set_usernames_RecipientType(&index, SRowSet, usernames_cc, flaglist, MAPI_CC);
mapi_set_usernames_RecipientType(&index, SRowSet, usernames_bcc, flaglist, MAPI_BCC);
/* FIXME no saving mail */
if (index == 0) {
printf("no valid recipients set\n");
return -1;
}
retval = ModifyRecipients(obj_message, SRowSet);
mapi_errstr("ModifyRecpients1", GetLastError());
MAPI_RETVAL_IF(retval, retval, mem_ctx);
SPropValue.ulPropTag = PR_SEND_INTERNET_ENCODING;
SPropValue.value.l = 0;
SRowSet_propcpy(mem_ctx, SRowSet, SPropValue);
/* mapidump_Recipients((const char **)usernames_to, SRowSet, flaglist); */
retval = ModifyRecipients (obj_message, SRowSet);
mapi_errstr("ModifyRecpients", GetLastError());
// mapidump_SRowSet(SRowSet);
if (retval != MAPI_E_SUCCESS) {
mapi_errstr(__PRETTY_FUNCTION__, GetLastError());
UNLOCK ();
return FALSE;
}
}