środa, 30 stycznia 2019

The class has sent information about printers to the email (class C++ Builder)

#include <Printers.hpp>
#include <mapi.h>
#include <string.h>

class email_Printers
{
private:
DEVMODE info_Mode;
        HANDLE m_Handle;
        LHANDLE l_Handle;
        LPMAPILOGON m_LPMAPILOGON;
        LPMAPILOGOFF m_LPMAPILOGOFF;
        LHANDLE m_handle_Session;
        LPMAPISENDMAIL m_LPMAPISENDMAIL;
AnsiString names_Printers;

char* Title;
        char *email;
char Note[1024];
public:
email_Printers(char* email_Adress)
{
                strcpy(email,email_Adress);
names_Printers=String(*(info_Mode.dmDeviceName));
Title="Information about Printers";
m_Handle = LoadLibrary("MAPI32.DLL");
                m_LPMAPILOGON = (LPMAPILOGON)GetProcAddress(m_Handle, "MAPILogon");
m_LPMAPISENDMAIL = (LPMAPISENDMAIL)GetProcAddress(m_Handle, "MAPISendMail");
m_LPMAPILOGOFF = (LPMAPILOGOFF)GetProcAddress(m_Handle, "MAPILogoff");

(*m_LPMAPILOGON)(0, NULL, NULL, 0, 0, &l_Handle);
MapiRecipDesc m_Send = {0, MAPI_TO, NULL, email_Adress, 0, NULL};
                AnsiString temp_String=Printer()->Printers->Text;
                strcpy(Note,temp_String.c_str());
                MapiRecipDesc m_Desc = {0, MAPI_TO, NULL, email_Adress, 0, NULL};
                MapiMessage Message = {0, Title,Note, NULL, NULL, NULL, 0, NULL, 1, &m_Desc, 0, NULL};



}
        ~email_Printers()
        {
          FreeLibrary(m_Handle);
        }
        void Send()
        {

         MapiRecipDesc m_Desc = {0, MAPI_TO, NULL, email, 0, NULL};
         MapiMessage Message = {0, Title,Note, NULL, NULL, NULL, 0, NULL, 1, &m_Desc, 0, NULL};

         (*m_LPMAPILOGON)(0,NULL,NULL,0,0,&m_handle_Session);
         (m_LPMAPISENDMAIL)(m_handle_Session,0,&Message,0,0);
         (*m_LPMAPILOGOFF)(m_handle_Session,0,0,0);

        }


};

Brak komentarzy:

Prześlij komentarz