Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Sending E-Mails

Status
Not open for further replies.

paubri

Programmer
Apr 25, 2005
21
ZA
Hi.

I have a program that I am trying to send e-mails through. I am using MAPI to send the message. I have the code as follows:

Code:
  MAPIModule := LoadLibrary(PChar(MAPIDLL));
  if MAPIModule=0
    then
      begin
        Result := -1
      end
    else
      begin
        try
          @SM := GetProcAddress(MAPIModule, 'MAPISendMail');
          if @SM <> nil
            then                              
              begin
                Result := mapiSendMail( 0, application.Handle, msg, MAPI_LOGON_UI, 0 );
              end
            else
              begin
                Result := 1
              end;
        finally
          FreeLibrary(MAPIModule);
        end;
      end;

The code works fine sending the e-mail, however, when I close the program, the following error message appears:

Code:
Project Theatre.exe reaised exception class EAccessViolation with message 'Access violation at address 7649F877. Read of address 7649F877.' Process stopped.

Does anyone know how I could prevent this from happening?

Thanks,
British
 
the line
Result := mapiSendMail( 0, application.Handle, msg, MAPI_LOGON_UI, 0 );

is not correct!
you must use SM. I see you're using the code sample from here :
they do it the right way...



--------------------------------------
What You See Is What You Get
 
When I use SM, it comes up with the same error message while I am trying to send the e-mail. It might be because I use Groupwise and not Outlook Express.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top