AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke Delphi Outlook (Exchange) MAPI Mail versenden
Thema durchsuchen
Ansicht
Themen-Optionen

Outlook (Exchange) MAPI Mail versenden

Ein Thema von Gruber_Hans_12345 · begonnen am 30. Jan 2008
Antwort Antwort
Gruber_Hans_12345

Registriert seit: 14. Aug 2004
1.439 Beiträge
 
Delphi 2007 Professional
 
#1

Outlook (Exchange) MAPI Mail versenden

  Alt 30. Jan 2008, 17:17
Ich habe ein Problem, beim versenden von Mail per MAPI, mit Outlook (Exchange)
und zwar stellt mir Outlook jedesmal ein, das es das Mail per RTF versenden will, und dann habe ich das Problem, das einige empfänger die Datei nicht lesen können (bekanntes winmail.dat)

Wenn ich in Outlook ein neues Mail sende, dann passt es (da wirds per only Text versendet), aber sobald ich es per MAPI versende (inklusive Dateianhang und co) wird es immer per RTF versendet (Man könnte dann jedesmal vorm versenden noch umstellen, aber das ist doch sehr mühselig)

Gibt es da irgendwo noch ne einstellunge, was ich da mitschicken kann?

Delphi-Quellcode:
type
    TAttachAccessArray = array[0..0] OF TMapiFileDesc;
    PAttachAccessArray = ^TAttachAccessArray;
var
    MapiMessage : TMapiMessage;
    Receip : TMapiRecipDesc;
    Attachments : PAttachAccessArray;
    AttachCount : integer;
    iCount : integer;
    FileName : string;
begin
    FillChar(MapiMessage, SizeOf(MapiMessage), #0);
    Attachments := nil;
    FillChar(Receip, SizeOf(Receip), #0);
    if Mail.Values['to'] <> 'then begin
        Receip.ulReserved := 0;
        Receip.ulRecipClass := MAPI_TO;
        Receip.lpszName := StrNew(PChar(Mail.Values['to']));
        Receip.lpszAddress := StrNew(PChar('SMTP:' + Mail.Values['to']));
        Receip.ulEIDSize := 0;
        MapiMessage.nRecipCount := 1;
        MapiMessage.lpRecips := @Receip;
    end;

    AttachCount := 0;
    for iCount := 0 to MaxInt do begin
        if Mail.Values['Attachment' + IntToStr(iCount)] = 'then break;
        AttachCount := AttachCount + 1;
    end;

    if AttachCount > 0 then begin
        GetMem(Attachments,SizeOf(TMapiFileDesc) * AttachCount);
        for iCount := 0 to (AttachCount - 1) do begin
            FileName := Mail.Values['Attachment' + IntToStr(iCount)];
            Attachments[iCount].ulReserved := 0;
            Attachments[iCount].flFlags := 0;
            Attachments[iCount].nPosition := ULONG($FFFFFFFF);
            Attachments[iCount].lpszPathName := StrNew(PChar(FileName));
            Attachments[iCount].lpszFileName := StrNew(PChar(ExtractFileName(FileName)));
            Attachments[iCount].lpFileType := nil;
        end;
        MapiMessage.nFileCount := AttachCount;
        MapiMessage.lpFiles := @Attachments^;
    end;

    if Mail.Values['subject'] <> 'then
        MapiMessage.lpszSubject := StrNew(PChar(Mail.Values['subject']));
    if Mail.Values['body'] <> 'then
        MapiMessage.lpszNoteText := StrNew(PChar(Mail.Values['body']));

    try
        if useGUI then
            Result := MapiSendMail(0, Handle, MapiMessage, MAPI_DIALOG*Ord(Handle <> 0) OR MAPI_LOGON_UI OR MAPI_NEW_SESSION, 0)
        else
            Result := MapiSendMail(0, Handle, MapiMessage, MAPI_DIALOG*Ord(Handle <> 0) OR MAPI_NEW_SESSION, 0);

        case Result of
            MAPI_E_AMBIGUOUS_RECIPIENT : LastError := 'A recipient matched more than one of the recipient descriptor structures and MAPI_DIALOG was not set. No message was sent.';
            MAPI_E_ATTACHMENT_NOT_FOUND : LastError := 'The specified attachment was not found. No message was sent.';
            MAPI_E_ATTACHMENT_OPEN_FAILURE : LastError := 'The specified attachment could not be open; no message was sent.';
            MAPI_E_BAD_RECIPTYPE : LastError := 'The type of a recipient was not MAPI_TO, MAPI_CC, or MAPI_BCC. No message was sent.';
            MAPI_E_FAILURE : LastError := 'One or more unspecified errors occurred; no message was sent.';
            MAPI_E_INSUFFICIENT_MEMORY : LastError := 'There was insufficient memory to proceed. No message was sent.';
            MAPI_E_LOGIN_FAILURE : LastError := 'There was no default logon, and the user failed to log on successfully when the logon dialog box was displayed. No message was sent.';
            MAPI_E_TEXT_TOO_LARGE : LastError := 'The text in the message was too large to sent; the message was not sent.';
            MAPI_E_TOO_MANY_FILES : LastError := 'There were too many file attachments; no message was sent.';
            MAPI_E_TOO_MANY_RECIPIENTS : LastError := 'There were too many recipients; no message was sent.';
            MAPI_E_UNKNOWN_RECIPIENT : LastError := 'A recipient did not appear in the address list; no message was sent.';
            MAPI_E_USER_ABORT : LastError := 'The user canceled one of the dialog boxes; no message was sent.';
            SUCCESS_SUCCESS : LastError := 'Alles OK';
        end;
    except
        On e:Exception do begin
            Result := 27;
            LastError := 'Internal Error '+e.Message;
        end;
    end;

    if AttachCount > 0 then begin
        for iCount := 0 to (AttachCount - 1) do begin
            strDispose(Attachments[iCount].lpszPathName);
            strDispose(Attachments[iCount].lpszFileName);
        end;
        FreeMem(Attachments);
    end;

    if assigned(MapiMessage.lpszSubject) then strDispose(MapiMessage.lpszSubject);
    if assigned(MapiMessage.lpszNoteText) then strDispose(MapiMessage.lpszNoteText);
    if assigned(Receip.lpszAddress) then strDispose(Receip.lpszAddress);
    if assigned(Receip.lpszName) then strDispose(Receip.lpszName);
end;
Gruss Hans

2B or not 2B, that is FF
  Mit Zitat antworten Zitat
Antwort Antwort


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:06 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