AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

MAPI Mailversand mit TB und Delphi 7

Ein Thema von zongo-joe · begonnen am 19. Feb 2025 · letzter Beitrag vom 20. Feb 2025
 
zongo-joe

Registriert seit: 8. Jun 2007
13 Beiträge
 
Delphi 7 Professional
 
#1

MAPI Mailversand mit TB und Delphi 7

  Alt 19. Feb 2025, 20:27
Nabend zusammen,
ich arbeite noch mit Delphi 7 (ja, funzt noch) und habe bisher unter Win10 keine Probleme mit dem MAPI Mailversand mit folgender Proc gehabt. Unter Win11 gehts nicht mehr; ich kriege keine Fehlermeldung, aber die Mail geht nicht raus. Ich habe Thunderbird als MailTo Standard-Client gesetzt und mit shellexecute(0, 'open', PChar(mmail), '', '', SW_NORMAL); wird auch TB aufgerufen. Aber warum geht das verdammte MAPI nicht?
Schon mal Danke für Eure Mühe.
BG Zongo

Delphi-Quellcode:
function SendFileMail(const FileName: TFileName; const Subject, BodyText,
  RecipAdress: String; bccx:boolean ): String;

  (* die registry muss folgende Werte aufweisen:
  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Messaging Subsystem\MAPI="1"
  HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Messaging Subsystem\MAPI="1"
  *)

var
  mMessage: TMapiMessage;
  mlpFiles: TMapiFileDesc;
  mRecips: TMapiRecipDesc;
begin
  if not FileExists(FileName) and (filename<>'') then
  begin
    Result := 'File "' + FileName + '" not found!';
    Exit;
  end;

  with mRecips do
  begin
    if not bccx then ulRecipClass := MAPI_TO else ulRecipClass := MAPI_BCC;
    lpszName := PChar(RecipAdress);
    lpszAddress := PChar(RecipAdress);
    ulEIDSize := 0;
    lpEntryID := nil;
  end;

  with mlpFiles do
  begin
    flFlags := 0;
    nPosition := 0;
    lpszPathName := PChar(FileName);
    lpszFileName := nil;
    lpFileType := nil;
  end;

  with mMessage do
  begin
    lpszSubject := PChar(Subject);
    lpszNoteText := PChar(BodyText);
    lpszMessageType := nil;
    lpszDateReceived := nil;
    lpszConversationID := nil;
    flFlags := 0;
    lpOriginator := nil;
    nRecipCount := 1;
    lpRecips := @mRecips;
    nFileCount := 1;
    lpFiles := @mlpFiles;
    if filename='then lpFiles:= nil;
    // if html then lpszNoteText:=nil; // dann wird der Anhang als HTML Message-Text benutzt
  end;

  case MapiSendMail(0, 0, mMessage, MAPI_LOGON_UI or MAPI_NEW_SESSION, 0) of
    MAPI_E_AMBIGUOUS_RECIPIENT:
      begin
        Result := 'A recipient matched more than one of the recipient descriptor structures and MAPI_DIALOG was not set!';
        mmonitor('SendFileMail answer: A recipient matched more than one of the recipient descriptor structures and MAPI_DIALOG was not set!');
      end;
    MAPI_E_ATTACHMENT_NOT_FOUND:
      begin
        Result := 'The specified attachment was not found!';
        mmonitor('SendFileMail answer: The specified attachment was not found!');
      end;
    MAPI_E_ATTACHMENT_OPEN_FAILURE:
      begin
        Result := 'The specified attachment could not be opened!';
        mmonitor('SendFileMail answer: The specified attachment could not be opened!');
      end;
    MAPI_E_BAD_RECIPTYPE:
      begin
        Result := 'The type of a recipient was not MAPI_TO, MAPI_CC, or MAPI_BCC!';
        mmonitor('SendFileMail answer: The type of a recipient was not MAPI_TO, MAPI_CC, or MAPI_BCC!');
      end;
    MAPI_E_FAILURE:
      begin
        Result := 'One or more unspecified errors occurred!';
        mmonitor('SendFileMail answer: One or more unspecified errors occurred!');
      end;
    MAPI_E_INSUFFICIENT_MEMORY:
      begin
        Result := 'There was insufficient memory to proceed!';
        mmonitor('SendFileMail answer: There was insufficient memory to proceed!');
      end;
    MAPI_E_LOGIN_FAILURE:
      begin
        Result := 'There was no default logon, and the user failed to log on successfully when the logon dialog box was displayed!';
        mmonitor('SendFileMail answer: There was no default logon, and the user failed to log on successfully when the logon dialog box was displayed!');
      end;
    MAPI_E_TEXT_TOO_LARGE:
      begin
        Result := 'The text in the message was too large to sent!';
        mmonitor('SendFileMail answer: The text in the message was too large to sent!');
      end;
    MAPI_E_TOO_MANY_FILES:
      begin
        Result := 'There were too many file attachments!';
        mmonitor('SendFileMail answer: There were too many file attachments!');
      end;
    MAPI_E_TOO_MANY_RECIPIENTS:
      begin
        Result := 'There were too many recipients!';
        mmonitor('SendFileMail answer: There were too many recipients!');
      end;
    MAPI_E_UNKNOWN_RECIPIENT:
      begin
        Result := 'A recipient did not appear in the address list!';
        mmonitor('SendFileMail answer: A recipient did not appear in the address list!');
      end;
    MAPI_E_USER_ABORT:
      begin
        Result := 'The user canceled one of the dialog boxes!';
        mmonitor('SendFileMail answer: The user canceled one of the dialog boxes!');
      end;
  end;
end; // von sendfilemail

Geändert von zongo-joe (19. Feb 2025 um 20:29 Uhr)
  Mit Zitat antworten Zitat
 

 

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:10 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz