<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[email versenden mit MAPI]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe im nezt folgenden Code zum Senden von emails gefunden:</p>
<pre><code class="language-cpp">void SendEMail(
    char *pszRecvAddress,             //Email
    char *pszTitle,                   //Mail Title
    char *pszNotes,                   //Mail Content
    char *pszFileName                 //attachment file name
)
{
    if ((NULL == pszRecvAddress) ||
        (NULL == pszTitle)       ||
        (NULL == pszNotes)       ||
        (NULL == pszFileName)
        )
    {
        printf(&quot;ERROR:NULL on SendEMail Function parameter!!!\n&quot;);
        return;
    }

    ULONG           uRetCode        = 0;
    LPMAPISENDMAIL  lpMAPISendMail  = NULL;
    HMODULE         hLibMAPI        = NULL;
    MapiRecipDesc   ReceiverInfo    = {0, MAPI_TO, &quot;&quot;, pszRecvAddress,0, 0};
    MapiFileDesc    AttachmentInfo  = {0, 0, 0xFFFFFFFF, pszFileName,&quot;&quot;, NULL};
    MapiMessage     MailInfo        =
        {
            0,
            pszTitle,
            pszNotes,
            NULL,
            NULL,
            NULL,
            MAPI_SENT,
            NULL,
            1,
            &amp;ReceiverInfo,
            1,
            &amp;AttachmentInfo
        };

    hLibMAPI = ::LoadLibrary(&quot;MAPI32.DLL&quot;);
    if (NULL == hLibMAPI)
    {
        printf(&quot;ERROR on Load MAPI32.DLL file!!! Cancel to auto send mail!!!\n&quot;);
        return;
    }
    lpMAPISendMail = (LPMAPISENDMAIL)::GetProcAddress(hLibMAPI,&quot;MAPISendMail&quot;);
    if (NULL == lpMAPISendMail)
    {
        printf(&quot;ERROR on Get MAPISendMail Function Address!!! Cancel to auto send mail!!!\n&quot;);
        goto ERR_EXIT;
    }

    uRetCode = lpMAPISendMail(0L, 0L, &amp;MailInfo, 0, 0);
    if (SUCCESS_SUCCESS == uRetCode)
    {
        printf(
            &quot;Success to Send mail to: %s, Mail Title:%s, Mail Notes:%s,Attachment file name:%s\n&quot;,
            pszRecvAddress,
            pszTitle,
            pszNotes,
            pszFileName
        );
    }
    else
    {
        printf(&quot;ERROR:failed Send mail!\n&quot;);
    }

ERR_EXIT:
    if (NULL != hLibMAPI)
    {
        ::FreeLibrary(hLibMAPI);
        hLibMAPI = NULL;
    }

    return;
</code></pre>
<p>Kompilert wird das ganze ohne Fehler.<br />
Testen wollt ich so</p>
<pre><code class="language-cpp">int main(int argc, char *argv[])
{
    SendEMail(&quot;test@test.de&quot;,&quot;test&quot;,&quot;test text&quot;,&quot;&quot;);
}
</code></pre>
<p>natürlich mit einer funktionierenden emailadresse.<br />
Meine WIN.INI habe ich kontrolliert, da steht unter [MAIL] MAPI=1, also ist der Dienst vorhanden. Outlook meldet sich auch mit &quot;Eine Anwendung versucht automatisch Nachrichten in ihrem Auftrag zu senden. Möchten Sie dies zulassen?&quot;<br />
Wenn ich das dann mit ja bestätige bekomme ich vom Programm aber die Fehlermeldung</p>
<blockquote>
<p>ERROR:failed Send mail!</p>
</blockquote>
<p>Kann mir jemand weiterhelfen bei dem Problem!?</p>
<p>Danke &amp; Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/173712/email-versenden-mit-mapi</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Jul 2026 22:43:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/173712.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 19 Feb 2007 09:27:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to email versenden mit MAPI on Mon, 19 Feb 2007 09:27:03 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe im nezt folgenden Code zum Senden von emails gefunden:</p>
<pre><code class="language-cpp">void SendEMail(
    char *pszRecvAddress,             //Email
    char *pszTitle,                   //Mail Title
    char *pszNotes,                   //Mail Content
    char *pszFileName                 //attachment file name
)
{
    if ((NULL == pszRecvAddress) ||
        (NULL == pszTitle)       ||
        (NULL == pszNotes)       ||
        (NULL == pszFileName)
        )
    {
        printf(&quot;ERROR:NULL on SendEMail Function parameter!!!\n&quot;);
        return;
    }

    ULONG           uRetCode        = 0;
    LPMAPISENDMAIL  lpMAPISendMail  = NULL;
    HMODULE         hLibMAPI        = NULL;
    MapiRecipDesc   ReceiverInfo    = {0, MAPI_TO, &quot;&quot;, pszRecvAddress,0, 0};
    MapiFileDesc    AttachmentInfo  = {0, 0, 0xFFFFFFFF, pszFileName,&quot;&quot;, NULL};
    MapiMessage     MailInfo        =
        {
            0,
            pszTitle,
            pszNotes,
            NULL,
            NULL,
            NULL,
            MAPI_SENT,
            NULL,
            1,
            &amp;ReceiverInfo,
            1,
            &amp;AttachmentInfo
        };

    hLibMAPI = ::LoadLibrary(&quot;MAPI32.DLL&quot;);
    if (NULL == hLibMAPI)
    {
        printf(&quot;ERROR on Load MAPI32.DLL file!!! Cancel to auto send mail!!!\n&quot;);
        return;
    }
    lpMAPISendMail = (LPMAPISENDMAIL)::GetProcAddress(hLibMAPI,&quot;MAPISendMail&quot;);
    if (NULL == lpMAPISendMail)
    {
        printf(&quot;ERROR on Get MAPISendMail Function Address!!! Cancel to auto send mail!!!\n&quot;);
        goto ERR_EXIT;
    }

    uRetCode = lpMAPISendMail(0L, 0L, &amp;MailInfo, 0, 0);
    if (SUCCESS_SUCCESS == uRetCode)
    {
        printf(
            &quot;Success to Send mail to: %s, Mail Title:%s, Mail Notes:%s,Attachment file name:%s\n&quot;,
            pszRecvAddress,
            pszTitle,
            pszNotes,
            pszFileName
        );
    }
    else
    {
        printf(&quot;ERROR:failed Send mail!\n&quot;);
    }

ERR_EXIT:
    if (NULL != hLibMAPI)
    {
        ::FreeLibrary(hLibMAPI);
        hLibMAPI = NULL;
    }

    return;
</code></pre>
<p>Kompilert wird das ganze ohne Fehler.<br />
Testen wollt ich so</p>
<pre><code class="language-cpp">int main(int argc, char *argv[])
{
    SendEMail(&quot;test@test.de&quot;,&quot;test&quot;,&quot;test text&quot;,&quot;&quot;);
}
</code></pre>
<p>natürlich mit einer funktionierenden emailadresse.<br />
Meine WIN.INI habe ich kontrolliert, da steht unter [MAIL] MAPI=1, also ist der Dienst vorhanden. Outlook meldet sich auch mit &quot;Eine Anwendung versucht automatisch Nachrichten in ihrem Auftrag zu senden. Möchten Sie dies zulassen?&quot;<br />
Wenn ich das dann mit ja bestätige bekomme ich vom Programm aber die Fehlermeldung</p>
<blockquote>
<p>ERROR:failed Send mail!</p>
</blockquote>
<p>Kann mir jemand weiterhelfen bei dem Problem!?</p>
<p>Danke &amp; Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1230964</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1230964</guid><dc:creator><![CDATA[fub0815]]></dc:creator><pubDate>Mon, 19 Feb 2007 09:27:03 GMT</pubDate></item></channel></rss>