AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke Delphi Ergänzung zu "Datei per E-Mail versenden"

Ergänzung zu "Datei per E-Mail versenden"

Ein Thema von franz · begonnen am 26. Jun 2009
Antwort Antwort
franz

Registriert seit: 23. Dez 2003
Ort: Bad Waldsee
112 Beiträge
 
Delphi 5 Professional
 
#1

Ergänzung zu "Datei per E-Mail versenden"

  Alt 26. Jun 2009, 09:43
Zu meinem Beitrag "Datei per E-Mail versenden" in der CodeLib möchte ich heute an dieser Stelle etwas ergänzen, da ich dem Thread nichts anhängen kann.

Immer wieder wurde ich per PN gefragt, was eingestellt werden muss, damit der Code auch mit Outlook funktioniert. Outlook verlangt zusätzlich zu Outlook Express die Angabe des Protokolls. Der Quellcode muss wie folgt geändert werden, damit er auch mit Outlook einwandfrei funktioniert:

Delphi-Quellcode:
function SendFileMail(const FileName: TFileName; const Subject, BodyText,
  RecipAdress: String): String;
var
  mMessage: TMapiMessage;
  mlpFiles: TMapiFileDesc;
  mRecips: TMapiRecipDesc;
begin
  if not FileExists(FileName) then
     begin
       Result := 'File "' + FileName + '" not found!';
       Exit;
     end;

  with mRecips do
    begin
      ulRecipClass := MAPI_TO;
      lpszName := PChar(RecipAdress);
      lpszAddress := PChar('SMTP:' + 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;
    end;

  case MapiSendMail(0, 0, mMessage, MAPI_LOGON_UI or MAPI_NEW_SESSION, 0) of
    MAPI_E_AMBIGUOUS_RECIPIENT:
      Result := 'A recipient matched more than one of the recipient descriptor structures and MAPI_DIALOG was not set!';
    MAPI_E_ATTACHMENT_NOT_FOUND:
      Result := 'The specified attachment was not found!';
    MAPI_E_ATTACHMENT_OPEN_FAILURE:
      Result := 'The specified attachment could not be open!';
    MAPI_E_BAD_RECIPTYPE:
      Result := 'The type of a recipient was not MAPI_TO, MAPI_CC, or MAPI_BCC!';
    MAPI_E_FAILURE:
      Result := 'One or more unspecified errors occurred!';
    MAPI_E_INSUFFICIENT_MEMORY:
      Result := 'There was insufficient memory to proceed!';
    MAPI_E_LOGIN_FAILURE:
      Result := 'There was no default logon, and the user failed to log on successfully when the logon dialog box was displayed!';
    MAPI_E_TEXT_TOO_LARGE:
      Result := 'The text in the message was too large to sent!';
    MAPI_E_TOO_MANY_FILES:
      Result := 'There were too many file attachments!';
    MAPI_E_TOO_MANY_RECIPIENTS:
      Result := 'There were too many recipients!';
    MAPI_E_UNKNOWN_RECIPIENT:
      Result := 'A recipient did not appear in the address list!';
    MAPI_E_USER_ABORT:
      Result := 'The user canceled one of the dialog boxes!';
  end;
end;
Das nächste Problem ist Windows 7. Die mapi funktioniert zumindest beim RC 1 nicht besonders gut. Ein paar mal lässt sich eine Datei über das Standard-Mailprogramm versenden, dann bleibt das aufrufende Programm hängen. Erst nach einem Windowsneustart funktioniert es wieder ein bis zwei mal. Vielleicht kann das jemand bestätigen und weiß eine Lösung.
Miniaturansicht angehängter Grafiken
win7_mapi_err_726.jpg  
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

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 06:51 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz