Module: wine Branch: master Commit: 6e33bfb76732b3d739454f2b9c42d1cfd1c32169 URL: http://source.winehq.org/git/wine.git/?a=commit;h=6e33bfb76732b3d739454f2b9c...
Author: Owen Rudge orudge@codeweavers.com Date: Thu Oct 1 14:11:07 2009 +0100
mapi32: Open the Drafts folder in preparation for creating a message.
---
dlls/mapi32/sendmail.c | 38 ++++++++++++++++++++++++++++++++++++++ include/mapitags.h | 1 + 2 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/dlls/mapi32/sendmail.c b/dlls/mapi32/sendmail.c index d644525..c7e0cfd 100644 --- a/dlls/mapi32/sendmail.c +++ b/dlls/mapi32/sendmail.c @@ -48,10 +48,18 @@ WINE_DEFAULT_DEBUG_CHANNEL(mapi); static ULONG sendmail_extended_mapi(LHANDLE mapi_session, ULONG_PTR uiparam, lpMapiMessage message, FLAGS flags, ULONG reserved) { + ULONG tags[] = {1, PR_IPM_DRAFTS_ENTRYID}; ULONG retval = MAPI_E_FAILURE; IMAPISession *session = NULL; IMAPITable* msg_table; LPSRowSet rows = NULL; + IMsgStore* msg_store; + IMAPIFolder* folder; + LPENTRYID entry_id; + LPSPropValue props; + ULONG entry_len; + DWORD obj_type; + ULONG values; HRESULT ret;
TRACE("Using Extended MAPI wrapper for MAPISendMail\n"); @@ -110,9 +118,39 @@ static ULONG sendmail_extended_mapi(LHANDLE mapi_session, ULONG_PTR uiparam, lpM if (!rows) goto logoff;
+ /* Open the message store */ + IMAPISession_OpenMsgStore(session, 0, rows->aRow[0].lpProps[0].Value.bin.cb, + (ENTRYID *) rows->aRow[0].lpProps[0].Value.bin.lpb, NULL, + MDB_NO_DIALOG | MAPI_BEST_ACCESS, &msg_store); + /* We don't need this any more */ FreeProws(rows);
+ /* First open the inbox, from which the drafts folder can be opened */ + if (IMsgStore_GetReceiveFolder(msg_store, NULL, 0, &entry_len, &entry_id, NULL) == S_OK) + { + IMsgStore_OpenEntry(msg_store, entry_len, entry_id, NULL, 0, &obj_type, (LPUNKNOWN*) &folder); + MAPIFreeBuffer(entry_id); + } + + /* Open the drafts folder, or failing that, try asking the message store for the outbox */ + if ((folder == NULL) || ((ret = IMAPIFolder_GetProps(folder, (LPSPropTagArray) tags, 0, &values, &props)) != S_OK)) + { + TRACE("Unable to open Drafts folder; opening Outbox instead\n"); + tags[1] = PR_IPM_OUTBOX_ENTRYID; + ret = IMsgStore_GetProps(msg_store, (LPSPropTagArray) tags, 0, &values, &props); + } + + if (ret != S_OK) + goto logoff; + + IMsgStore_OpenEntry(msg_store, props[0].Value.bin.cb, (LPENTRYID) props[0].Value.bin.lpb, + NULL, MAPI_MODIFY, &obj_type, (LPUNKNOWN *) &folder); + + /* Free up the resources we've used */ + IMAPIFolder_Release(folder); + IMsgStore_Release(msg_store); + logoff: ; IMAPISession_Logoff(session, (ULONG) NULL, 0, 0); IMAPISession_Release(session); diff --git a/include/mapitags.h b/include/mapitags.h index abeee48..48f4dc1 100644 --- a/include/mapitags.h +++ b/include/mapitags.h @@ -452,6 +452,7 @@ #define PR_AB_PROVIDER_ID PROP_TAG(PT_BINARY,0x3615) #define PR_DEFAULT_VIEW_ENTRYID PROP_TAG(PT_BINARY,0x3616) #define PR_ASSOC_CONTENT_COUNT PROP_TAG(PT_I4,0x3617) +#define PR_IPM_DRAFTS_ENTRYID PROP_TAG(PT_BINARY,0x36D7) #define PR_ATTACHMENT_X400_PARAMETERS PROP_TAG(PT_BINARY,0x3700) #define PR_ATTACH_DATA_OBJ PROP_TAG(PT_OBJECT,0x3701) #define PR_ATTACH_DATA_BIN PROP_TAG(PT_BINARY,0x3701)