コード例 #1
0
ファイル: sendmail.c プロジェクト: RareHare/reactos
/**************************************************************************
 *  MAPISendMail	(MAPI32.211)
 *
 * Send a mail.
 *
 * PARAMS
 *  session  [I] Handle to a MAPI session.
 *  uiparam  [I] Parent window handle.
 *  message  [I] Pointer to a MAPIMessage structure.
 *  flags    [I] Flags.
 *  reserved [I] Reserved, pass 0.
 *
 * RETURNS
 *  Success: SUCCESS_SUCCESS
 *  Failure: MAPI_E_FAILURE
 *
 */
ULONG WINAPI MAPISendMail( LHANDLE session, ULONG_PTR uiparam,
    lpMapiMessage message, FLAGS flags, ULONG reserved )
{
    WCHAR msg_title[READ_BUF_SIZE], error_msg[READ_BUF_SIZE];

    /* Check to see if we have a Simple MAPI provider loaded */
    if (mapiFunctions.MAPISendMail)
        return mapiFunctions.MAPISendMail(session, uiparam, message, flags, reserved);

    /* Check if we have an Extended MAPI provider - if so, use our wrapper */
    if (MAPIInitialize(NULL) == S_OK)
        return sendmail_extended_mapi(session, uiparam, message, flags, reserved);

    /* Display an error message since we apparently have no mail clients */
    LoadStringW(hInstMAPI32, IDS_NO_MAPI_CLIENT, error_msg, sizeof(error_msg) / sizeof(WCHAR));
    LoadStringW(hInstMAPI32, IDS_SEND_MAIL, msg_title, sizeof(msg_title) / sizeof(WCHAR));

    MessageBoxW((HWND) uiparam, error_msg, msg_title, MB_ICONEXCLAMATION);

    return MAPI_E_NOT_SUPPORTED;
}
コード例 #2
0
ファイル: sendmail.c プロジェクト: AlexSteel/wine
/**************************************************************************
 *  MAPISendMailW	(MAPI32.256)
 *
 * Send a mail.
 *
 * PARAMS
 *  session  [I] Handle to a MAPI session.
 *  uiparam  [I] Parent window handle.
 *  message  [I] Pointer to a MAPIMessageW structure.
 *  flags    [I] Flags.
 *  reserved [I] Reserved, pass 0.
 *
 * RETURNS
 *  Success: SUCCESS_SUCCESS
 *  Failure: MAPI_E_FAILURE
 *
 */
ULONG WINAPI MAPISendMailW(LHANDLE session, ULONG_PTR uiparam,
    lpMapiMessageW message, FLAGS flags, ULONG reserved)
{
    WCHAR msg_title[READ_BUF_SIZE], error_msg[READ_BUF_SIZE];

    /* Check to see if we have a Simple MAPI provider loaded */
    if (mapiFunctions.MAPISendMailW)
        return mapiFunctions.MAPISendMailW(session, uiparam, message, flags, reserved);

    /* Check if we have an Extended MAPI provider - if so, use our wrapper */
    if (MAPIInitialize(NULL) == S_OK)
        return sendmail_extended_mapi(session, uiparam, message, flags);

    if (mapiFunctions.MAPISendMail)
    {
        MapiMessage messageA;
        ULONG ret;

        if (flags & MAPI_FORCE_UNICODE)
            return MAPI_E_UNICODE_NOT_SUPPORTED;

        /* Convert to ANSI and send to MAPISendMail */
        ZeroMemory(&messageA, sizeof(MapiMessage));

        messageA.lpszSubject = convert_from_unicode(message->lpszSubject);
        messageA.lpszNoteText = convert_from_unicode(message->lpszNoteText);
        messageA.lpszMessageType = convert_from_unicode(message->lpszMessageType);
        messageA.lpszDateReceived = convert_from_unicode(message->lpszDateReceived);
        messageA.lpszConversationID = convert_from_unicode(message->lpszConversationID);
        messageA.flFlags = message->flFlags;
        messageA.lpOriginator = convert_recipient_from_unicode(message->lpOriginator, NULL);
        messageA.nRecipCount = message->nRecipCount;
        messageA.nFileCount = message->nFileCount;

        if (message->nRecipCount && message->lpRecips)
        {
            lpMapiRecipDesc recipsA;
            unsigned int i;

            recipsA = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MapiRecipDesc) * message->nRecipCount);

            for (i = 0; i < message->nRecipCount; i++)
            {
                convert_recipient_from_unicode(&message->lpRecips[i], &recipsA[i]);
            }

            messageA.lpRecips = recipsA;
        }

        if (message->nFileCount && message->lpFiles)
        {
            lpMapiFileDesc filesA;
            unsigned int i;

            filesA = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MapiFileDesc) * message->nFileCount);

            for (i = 0; i < message->nFileCount; i++)
            {
                filesA[i].flFlags = message->lpFiles[i].flFlags;
                filesA[i].nPosition = message->lpFiles[i].nPosition;
                filesA[i].lpszPathName = convert_from_unicode(message->lpFiles[i].lpszPathName);
                filesA[i].lpszFileName = convert_from_unicode(message->lpFiles[i].lpszFileName);
                filesA[i].lpFileType = message->lpFiles[i].lpFileType;
            }

            messageA.lpFiles = filesA;
        }

        ret = mapiFunctions.MAPISendMail(session, uiparam, &messageA, flags, reserved);

        /* Now free everything we allocated */
        if (message->lpOriginator)
        {
            HeapFree(GetProcessHeap(), 0, messageA.lpOriginator->lpszName);
            HeapFree(GetProcessHeap(), 0, messageA.lpOriginator->lpszAddress);
            HeapFree(GetProcessHeap(), 0, messageA.lpOriginator);
        }

        if (message->nRecipCount && message->lpRecips)
        {
            unsigned int i;

            for (i = 0; i < message->nRecipCount; i++)
            {
                HeapFree(GetProcessHeap(), 0, messageA.lpRecips[i].lpszName);
                HeapFree(GetProcessHeap(), 0, messageA.lpRecips[i].lpszAddress);
            }

            HeapFree(GetProcessHeap(), 0, messageA.lpRecips);
        }

        if (message->nFileCount && message->lpFiles)
        {
            unsigned int i;

            for (i = 0; i < message->nFileCount; i++)
            {
                HeapFree(GetProcessHeap(), 0, messageA.lpFiles[i].lpszPathName);
                HeapFree(GetProcessHeap(), 0, messageA.lpFiles[i].lpszFileName);
            }

            HeapFree(GetProcessHeap(), 0, messageA.lpFiles);
        }

        HeapFree(GetProcessHeap(), 0, messageA.lpszSubject);
        HeapFree(GetProcessHeap(), 0, messageA.lpszNoteText);
        HeapFree(GetProcessHeap(), 0, messageA.lpszDateReceived);
        HeapFree(GetProcessHeap(), 0, messageA.lpszConversationID);

        return ret;
    }

    /* Display an error message since we apparently have no mail clients */
    LoadStringW(hInstMAPI32, IDS_NO_MAPI_CLIENT, error_msg, sizeof(error_msg) / sizeof(WCHAR));
    LoadStringW(hInstMAPI32, IDS_SEND_MAIL, msg_title, sizeof(msg_title) / sizeof(WCHAR));

    MessageBoxW((HWND) uiparam, error_msg, msg_title, MB_ICONEXCLAMATION);

    return MAPI_E_NOT_SUPPORTED;
}
コード例 #3
0
ファイル: sendmail.c プロジェクト: AlexSteel/wine
/**************************************************************************
 *  MAPISendMail	(MAPI32.211)
 *
 * Send a mail.
 *
 * PARAMS
 *  session  [I] Handle to a MAPI session.
 *  uiparam  [I] Parent window handle.
 *  message  [I] Pointer to a MAPIMessage structure.
 *  flags    [I] Flags.
 *  reserved [I] Reserved, pass 0.
 *
 * RETURNS
 *  Success: SUCCESS_SUCCESS
 *  Failure: MAPI_E_FAILURE
 *
 */
ULONG WINAPI MAPISendMail( LHANDLE session, ULONG_PTR uiparam,
    lpMapiMessage message, FLAGS flags, ULONG reserved )
{
    WCHAR msg_title[READ_BUF_SIZE], error_msg[READ_BUF_SIZE];

    /* Check to see if we have a Simple MAPI provider loaded */
    if (mapiFunctions.MAPISendMail)
        return mapiFunctions.MAPISendMail(session, uiparam, message, flags, reserved);

    /* Check if we have an Extended MAPI provider - if so, use our wrapper */
    if (MAPIInitialize(NULL) == S_OK)
    {
        MapiMessageW messageW;
        ULONG ret;

        ZeroMemory(&messageW, sizeof(MapiMessageW));

        /* Convert the entries we need to Unicode */
        messageW.lpszSubject = convert_to_unicode(message->lpszSubject);
        messageW.lpszNoteText = convert_to_unicode(message->lpszNoteText);
        messageW.nFileCount = message->nFileCount;

        if (message->nFileCount && message->lpFiles)
        {
            lpMapiFileDescW filesW;
            unsigned int i;

            filesW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MapiFileDescW) * message->nFileCount);

            for (i = 0; i < message->nFileCount; i++)
            {
                filesW[i].lpszPathName = convert_to_unicode(message->lpFiles[i].lpszPathName);
                filesW[i].lpszFileName = convert_to_unicode(message->lpFiles[i].lpszFileName);
            }

            messageW.lpFiles = filesW;
        }

        ret = sendmail_extended_mapi(session, uiparam, &messageW, flags);

        /* Now free everything we allocated */
        if (message->nFileCount && message->lpFiles)
        {
            unsigned int i;

            for (i = 0; i < message->nFileCount; i++)
            {
                HeapFree(GetProcessHeap(), 0, messageW.lpFiles[i].lpszPathName);
                HeapFree(GetProcessHeap(), 0, messageW.lpFiles[i].lpszFileName);
            }

            HeapFree(GetProcessHeap(), 0, messageW.lpFiles);
        }

        HeapFree(GetProcessHeap(), 0, messageW.lpszSubject);
        HeapFree(GetProcessHeap(), 0, messageW.lpszNoteText);

        return ret;
    }

    /* Display an error message since we apparently have no mail clients */
    LoadStringW(hInstMAPI32, IDS_NO_MAPI_CLIENT, error_msg, sizeof(error_msg) / sizeof(WCHAR));
    LoadStringW(hInstMAPI32, IDS_SEND_MAIL, msg_title, sizeof(msg_title) / sizeof(WCHAR));

    MessageBoxW((HWND) uiparam, error_msg, msg_title, MB_ICONEXCLAMATION);

    return MAPI_E_NOT_SUPPORTED;
}