Call Outlook in C ++ Builder Send Mail

zhaozj2021-02-12  214

Call Outlook in C Builder Send Mail

1) First, add #include "mapi.hpp" in the CPP file.

Write down the following code when you need to call the email: void __fastcall tform1 :: button1click (TOBJECT * Sender) {

TMAPIMESSAGE MAPIMESSAGE; Cardinal Merror;

MapiMessage.ulReserved = 0; MapiMessage.lpszSubject = NULL; MapiMessage.lpszNoteText = RichEdit1-> Lines-> Text.c_str (); MapiMessage.lpszMessageType = NULL; MapiMessage.lpszDateReceived = NULL; MapiMessage.lpszConversationID = NULL; MapiMessage.flFlags = 0; mapimessage.lporiginator = null; mapimessage.nrecipcount = 0; mapimessage.lprecips = null; mapimessage.nfilecount = 0; mapimessage.lpfiles = null;

Merror = mapisndmail (0, Reinterpret_cast , mapimssis, mapi_dialog | mapi_logon_ui | mapi_new_session, 0);

IF (Merror) ShowMessage ("Send Mail Errors!");

}

This will call Outlook to send an email.

转载请注明原文地址:https://www.9cbs.com/read-7527.html

New Post(0)