简体   繁体   中英

Delphi MapiSendMail Crashes on Windows 7 64-bit

I have windows 7 64-bit and my delphi sendmail crashes when trying to send an email for the second time or sometimes even just waiting for the first send mail to complete. Same application works with windows vista.

Below is my test procedure in sending the mail:

procedure TForm1.SendMail(const Subject, FileName: String);
var tmpName2, PFullFilePath, PSubject : Array[0..MAX_PATH] of AnsiChar;
    MapiMessage  : TMapiMessage;
    MapiFileDesc : TMapiFileDesc;
    MError       : Cardinal;
begin
  with MapiFileDesc do
  begin
     ulReserved:=0;
     flFlags:=0;
     nPosition:=Cardinal(-1);
     StrPCopy(PFullFilePath, FileName);
     lpszPathName:=PFullFilePath;
     StrPCopy(tmpName2,ExtractFileName(FileName));
     lpszFileName:=tmpName2;
     lpFileType:=nil;
   end;

   with MapiMessage do
   begin
      ulReserved := 0;
      StrPCopy(PSubject, Subject);
      lpszSubject := PSubject;
      lpszNoteText := nil;
      lpszMessageType := nil;
      lpszDateReceived := nil;
      lpszConversationID := nil;
      flFlags := 0;
      lpOriginator := nil;
      nRecipCount := 0;
      lpRecips := nil;
      nFileCount := 1;
      lpFiles := @MapiFileDesc;
   end;

   MError:=MapiSendMail(0,Application.Handle, MapiMessage, MAPI_DIALOG or MAPI_LOGON_UI or MAPI_NEW_SESSION, 0);

   if MError<>0 then
      Raise Exception.CreateFmt(IntToStr(MError), [MError]);
end;

Error/Crash Message that I get:

Problem signature:
Problem Event Name: APPCRASH
Application Name: mapitestp.exe
Application Version: 0.0.0.0
Application Timestamp: 4d82c905
Fault Module Name: ntdll.dll
Fault Module Version: 6.1.7600.16559
Fault Module Timestamp: 4ba9b29c
Exception Code: 4000001f
Exception Offset: 000a1dcf OS Version: 6.1.7600.2.0.0.256.1
Locale ID: 1033
Additional Information 1: d1ab
Additional Information 2: d1ab624ec7d094c26a73530c245a3468
Additional Information 3: d1ab
Additional Information 4: d1ab624ec7d094c26a73530c245a3468

Any help or idea would be very much appreciated. Thanks

Take a look at this Link at Embarcadero, it may be some Unicode issue.

Hope it helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM