Knowledge Base

MailBee.SMTP ActiveX Visual C++ Sample

This article shows how to use MailBee.SMTP ActiveX to send a simple email in Visual C++. Be sure to copy MailBee.dll into your Visual C++ project folder. It can send to any SMTP-compliant server including Exchange.

For 64-bit application, MailBee64.dll should be used instead.

#include <stdio.h>
#import "mailbee.dll" no_namespace

int main(int argc, char* argv[])
    if (OleInitialize(NULL) == S_OK) {
            ISMTPPtr pMailer("MailBee.SMTP");

            // Logging is useful for troubleshooting
            pMailer->LogFilePath = "C:\\Temp\\log.txt";
            pMailer->EnableLogging = TRUE;
            pMailer->LicenseKey = "your MailBee ActiveX license key";
            pMailer->ServerName = "";

            // Using authentication is required by most SMTP servers
            pMailer->AuthMethod = 1;
            pMailer->UserName = "user";
            pMailer->Password = "password";

            // Set e-mail values
            pMailer->FromAddr = "User <>";
            pMailer->ToAddr = "John Doe <>";
            pMailer->Subject = "Hello";
            pMailer->BodyFormat = 1;
            pMailer->BodyText = "<html>This is body</html>";
            pMailer->Charset = "UTF-8";
            // You can also add attachments, images, plain-text, etc

            if (pMailer->Send()) {
                printf("Send succeeded");
            } else {
                // You can also use properties like ErrCode
                printf("Send failed, see log for details");

    return 0;