446
442
rowset.aRow[i].lpProps[1].value.d,
447
443
&obj_message, 0);
448
444
if (GetLastError() == MAPI_E_SUCCESS) {
449
struct SPropValue *lpProps;
452
SPropTagArray = set_SPropTagArray(mem_ctx, 0x1, PR_HASATTACH);
453
lpProps = talloc_zero(mem_ctx, struct SPropValue);
454
retval = GetProps(&obj_message, SPropTagArray, &lpProps, &count);
455
MAPIFreeBuffer(SPropTagArray);
456
if (retval != MAPI_E_SUCCESS) return retval;
458
aRow.ulAdrEntryPad = 0;
459
aRow.cValues = count;
460
aRow.lpProps = lpProps;
462
retval = octool_message(mem_ctx, &obj_message);
464
has_attach = (const uint8_t *) get_SPropValue_SRow_data(&aRow, PR_HASATTACH);
466
/* If we have attachments, retrieve them */
467
if (has_attach && *has_attach) {
468
mapi_object_init(&obj_tb_attach);
469
retval = GetAttachmentTable(&obj_message, &obj_tb_attach);
470
if (retval == MAPI_E_SUCCESS) {
471
SPropTagArray = set_SPropTagArray(mem_ctx, 0x1, PR_ATTACH_NUM);
472
retval = SetColumns(&obj_tb_attach, SPropTagArray);
473
if (retval != MAPI_E_SUCCESS) return retval;
474
MAPIFreeBuffer(SPropTagArray);
476
retval = QueryRows(&obj_tb_attach, 0xa, TBL_ADVANCE, &rowset_attach);
477
if (retval != MAPI_E_SUCCESS) return retval;
479
for (j = 0; j < rowset_attach.cRows; j++) {
480
attach_num = (const uint32_t *)find_SPropValue_data(&(rowset_attach.aRow[j]), PR_ATTACH_NUM);
481
retval = OpenAttach(&obj_message, *attach_num, &obj_attach);
482
if (retval == MAPI_E_SUCCESS) {
483
struct SPropValue *lpProps2;
486
SPropTagArray = set_SPropTagArray(mem_ctx, 0x3,
488
PR_ATTACH_LONG_FILENAME,
490
lpProps2 = talloc_zero(mem_ctx, struct SPropValue);
491
retval = GetProps(&obj_attach, SPropTagArray, &lpProps2, &count2);
492
MAPIFreeBuffer(SPropTagArray);
493
if (retval != MAPI_E_SUCCESS) return retval;
495
aRow.ulAdrEntryPad = 0;
496
aRow.cValues = count2;
497
aRow.lpProps = lpProps2;
499
attach_filename = get_filename(octool_get_propval(&aRow, PR_ATTACH_LONG_FILENAME));
500
if (!attach_filename || (attach_filename && !strcmp(attach_filename, ""))) {
501
attach_filename = get_filename(octool_get_propval(&aRow, PR_ATTACH_FILENAME));
503
attach_size = (const uint32_t *) octool_get_propval(&aRow, PR_ATTACH_SIZE);
504
printf("[%u] %s (%u Bytes)\n", j, attach_filename, attach_size ? *attach_size : 0);
506
if (oclient->store_folder) {
507
status = store_attachment(obj_attach, attach_filename, attach_size ? *attach_size : 0, oclient);
508
if (status == false) {
509
printf("A Problem was encountered while storing attachments on the filesystem\n");
510
MAPI_RETVAL_IF(status == false, MAPI_E_UNABLE_TO_COMPLETE, mem_ctx);
514
MAPIFreeBuffer(lpProps2);
445
if (oclient->summary) {
446
mapidump_message_summary(&obj_message);
448
struct SPropValue *lpProps;
451
SPropTagArray = set_SPropTagArray(mem_ctx, 0x1, PR_HASATTACH);
452
lpProps = talloc_zero(mem_ctx, struct SPropValue);
453
retval = GetProps(&obj_message, SPropTagArray, &lpProps, &count);
454
MAPIFreeBuffer(SPropTagArray);
455
if (retval != MAPI_E_SUCCESS) return retval;
457
aRow.ulAdrEntryPad = 0;
458
aRow.cValues = count;
459
aRow.lpProps = lpProps;
461
retval = octool_message(mem_ctx, &obj_message);
463
has_attach = (const uint8_t *) get_SPropValue_SRow_data(&aRow, PR_HASATTACH);
465
/* If we have attachments, retrieve them */
466
if (has_attach && *has_attach) {
467
mapi_object_init(&obj_tb_attach);
468
retval = GetAttachmentTable(&obj_message, &obj_tb_attach);
469
if (retval == MAPI_E_SUCCESS) {
470
SPropTagArray = set_SPropTagArray(mem_ctx, 0x1, PR_ATTACH_NUM);
471
retval = SetColumns(&obj_tb_attach, SPropTagArray);
472
if (retval != MAPI_E_SUCCESS) return retval;
473
MAPIFreeBuffer(SPropTagArray);
475
retval = QueryRows(&obj_tb_attach, 0xa, TBL_ADVANCE, &rowset_attach);
476
if (retval != MAPI_E_SUCCESS) return retval;
478
for (j = 0; j < rowset_attach.cRows; j++) {
479
attach_num = (const uint32_t *)find_SPropValue_data(&(rowset_attach.aRow[j]), PR_ATTACH_NUM);
480
retval = OpenAttach(&obj_message, *attach_num, &obj_attach);
481
if (retval == MAPI_E_SUCCESS) {
482
struct SPropValue *lpProps2;
485
SPropTagArray = set_SPropTagArray(mem_ctx, 0x3,
487
PR_ATTACH_LONG_FILENAME,
489
lpProps2 = talloc_zero(mem_ctx, struct SPropValue);
490
retval = GetProps(&obj_attach, SPropTagArray, &lpProps2, &count2);
491
MAPIFreeBuffer(SPropTagArray);
492
if (retval != MAPI_E_SUCCESS) return retval;
494
aRow.ulAdrEntryPad = 0;
495
aRow.cValues = count2;
496
aRow.lpProps = lpProps2;
498
attach_filename = get_filename(octool_get_propval(&aRow, PR_ATTACH_LONG_FILENAME));
499
if (!attach_filename || (attach_filename && !strcmp(attach_filename, ""))) {
500
attach_filename = get_filename(octool_get_propval(&aRow, PR_ATTACH_FILENAME));
502
attach_size = (const uint32_t *) octool_get_propval(&aRow, PR_ATTACH_SIZE);
503
printf("[%u] %s (%u Bytes)\n", j, attach_filename, attach_size ? *attach_size : 0);
505
if (oclient->store_folder) {
506
status = store_attachment(obj_attach, attach_filename, attach_size ? *attach_size : 0, oclient);
507
if (status == false) {
508
printf("A Problem was encountered while storing attachments on the filesystem\n");
509
MAPI_RETVAL_IF(status == false, MAPI_E_UNABLE_TO_COMPLETE, mem_ctx);
513
MAPIFreeBuffer(lpProps2);
518
MAPIFreeBuffer(lpProps);
519
MAPIFreeBuffer(lpProps);
522
522
mapi_object_release(&obj_message);
526
526
mapi_object_release(&obj_table);
527
527
mapi_object_release(&obj_inbox);
528
528
mapi_object_release(&obj_tis);
774
774
if (retval != MAPI_E_SUCCESS) return retval;
776
776
/* Recipients operations */
777
SPropTagArray = set_SPropTagArray(mem_ctx, 0x6,
777
SPropTagArray = set_SPropTagArray(mem_ctx, 0xA,
779
PR_DISPLAY_NAME_UNICODE,
780
PR_7BIT_DISPLAY_NAME,
782
PR_TRANSMITTABLE_DISPLAY_NAME_UNICODE,
783
PR_EMAIL_ADDRESS_UNICODE,
786
PR_7BIT_DISPLAY_NAME_UNICODE,
787
PR_SMTP_ADDRESS_UNICODE);
785
789
oclient->usernames = collapse_recipients(mem_ctx, oclient);
787
791
/* ResolveNames */
788
792
retval = ResolveNames(mapi_object_get_session(&obj_message), (const char **)oclient->usernames,
789
SPropTagArray, &SRowSet, &flaglist, 0);
793
SPropTagArray, &SRowSet, &flaglist, MAPI_UNICODE);
790
794
MAPIFreeBuffer(SPropTagArray);
791
795
if (retval != MAPI_E_SUCCESS) return retval;
1057
1061
lpProps = talloc_array(mem_ctx, struct SPropValue, 2);
1059
1063
if (oclient->subject) {
1060
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PR_CONVERSATION_TOPIC,
1064
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PR_CONVERSATION_TOPIC_UNICODE,
1061
1065
(const void *) oclient->subject);
1062
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PR_NORMALIZED_SUBJECT,
1066
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PR_NORMALIZED_SUBJECT_UNICODE,
1063
1067
(const void *) oclient->subject);
1065
1069
if (oclient->pr_body) {
1066
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PR_BODY, (const void *)oclient->pr_body);
1070
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PR_BODY_UNICODE, (const void *)oclient->pr_body);
1068
1072
if (oclient->location) {
1069
1073
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PidLidLocation, (const void *)oclient->location);
1224
1228
lpProps = talloc_array(mem_ctx, struct SPropValue, 2);
1226
1230
if (oclient->card_name) {
1227
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PR_NORMALIZED_SUBJECT, (const void *)oclient->card_name);
1231
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PR_NORMALIZED_SUBJECT_UNICODE, (const void *)oclient->card_name);
1228
1232
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PidLidFileUnder, (const void *)oclient->card_name);
1229
1233
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, SPropTagArray->aulPropTag[0], (const void *)oclient->card_name);
1231
1235
if (oclient->full_name) {
1232
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PR_DISPLAY_NAME, (const void *)oclient->full_name);
1236
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PR_DISPLAY_NAME_UNICODE, (const void *)oclient->full_name);
1234
1238
if (oclient->email) {
1235
1239
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PidLidEmail1OriginalDisplayName, (const void *)oclient->email);
1427
1431
lpProps = talloc_array(mem_ctx, struct SPropValue, 2);
1429
1433
if (oclient->card_name) {
1430
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PR_CONVERSATION_TOPIC, (const void *)oclient->card_name);
1431
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PR_SUBJECT, (const void *)oclient->card_name);
1432
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PR_NORMALIZED_SUBJECT, (const void *)oclient->card_name);
1433
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PR_BODY, (const void *)oclient->card_name);
1434
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PR_CONVERSATION_TOPIC_UNICODE, (const void *)oclient->card_name);
1435
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PR_SUBJECT_UNICODE, (const void *)oclient->card_name);
1436
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PR_NORMALIZED_SUBJECT_UNICODE, (const void *)oclient->card_name);
1437
lpProps = add_SPropValue(mem_ctx, lpProps, &cValues, PR_BODY_UNICODE, (const void *)oclient->card_name);
1436
1440
if (!oclient->update) {
1788
1787
SRowSet.aRow[i].lpProps[1].value.d,
1789
1788
&obj_message, 0);
1790
1789
if (retval != MAPI_E_NOT_FOUND) {
1791
retval = GetPropsAll(&obj_message, &properties_array);
1792
if (retval == MAPI_E_SUCCESS) {
1793
id = talloc_asprintf(mem_ctx, ": %"PRIX64"/%"PRIX64,
1794
SRowSet.aRow[i].lpProps[0].value.d,
1795
SRowSet.aRow[i].lpProps[1].value.d);
1796
mapi_SPropValue_array_named(&obj_message,
1800
mapidump_message(&properties_array, id);
1802
case olFolderCalendar:
1803
mapidump_appointment(&properties_array, id);
1805
case olFolderContacts:
1806
mapidump_contact(&properties_array, id);
1809
mapidump_task(&properties_array, id);
1812
mapidump_note(&properties_array, id);
1790
if (oclient->summary) {
1791
mapidump_message_summary(&obj_message);
1793
retval = GetPropsAll(&obj_message, &properties_array);
1794
if (retval == MAPI_E_SUCCESS) {
1795
id = talloc_asprintf(mem_ctx, ": %"PRIX64"/%"PRIX64,
1796
SRowSet.aRow[i].lpProps[0].value.d,
1797
SRowSet.aRow[i].lpProps[1].value.d);
1798
mapi_SPropValue_array_named(&obj_message,
1802
mapidump_message(&properties_array, id, NULL);
1804
case olFolderCalendar:
1805
mapidump_appointment(&properties_array, id);
1807
case olFolderContacts:
1808
mapidump_contact(&properties_array, id);
1811
mapidump_task(&properties_array, id);
1814
mapidump_note(&properties_array, id);
1816
mapi_object_release(&obj_message);
1820
mapi_object_release(&obj_message);
2799
2830
{"pf", 0, POPT_ARG_NONE, NULL, OPT_PF, "access public folders instead of mailbox", NULL },
2800
2831
{"profile", 'p', POPT_ARG_STRING, NULL, OPT_PROFILE, "set the profile name", NULL },
2801
2832
{"password", 'P', POPT_ARG_STRING, NULL, OPT_PASSWORD, "set the profile password", NULL },
2833
{"username", 0, POPT_ARG_STRING, NULL, OPT_USERNAME, "set the username of the mailbox to use", NULL },
2802
2834
{"sendmail", 'S', POPT_ARG_NONE, NULL, OPT_SENDMAIL, "send a mail", NULL },
2803
2835
{"sendappointment", 0, POPT_ARG_NONE, NULL, OPT_SENDAPPOINTMENT, "send an appointment", NULL },
2804
2836
{"sendcontact", 0, POPT_ARG_NONE, NULL, OPT_SENDCONTACT, "send a contact", NULL },
2805
2837
{"sendtask", 0, POPT_ARG_NONE, NULL, OPT_SENDTASK, "send a task", NULL },
2806
2838
{"sendnote", 0, POPT_ARG_NONE, NULL, OPT_SENDNOTE, "send a note", NULL },
2807
2839
{"fetchmail", 'F', POPT_ARG_NONE, NULL, OPT_FETCHMAIL, "fetch user INBOX mails", NULL },
2840
{"fetchsummary", 0, POPT_ARG_NONE, NULL, OPT_FETCHSUMMARY, "fetch message summaries only", NULL },
2808
2841
{"storemail", 'G', POPT_ARG_STRING, NULL, OPT_STOREMAIL, "retrieve a mail on the filesystem", NULL },
2809
2842
{"fetch-items", 'i', POPT_ARG_STRING, NULL, OPT_FETCHITEMS, "fetch specified user INBOX items", NULL },
2810
2843
{"freebusy", 0, POPT_ARG_STRING, NULL, OPT_FREEBUSY, "display free / busy information for the specified user", NULL },