![]() |
Outlook (Exchange) MAPI Mail versenden
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; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:39 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