Já používám v Delphi posílání mailu přes MAPI, ne přes Shell. Udělal jsem si na to proceduru, můžeš jí použít (ostatní také) dle libost. Lze snadno upravit na více příjemců, více souborů atd:
uses SysUtils, MAPI, Forms, Windows;
function SendMail (const AdRcpt: string; NmRcpt: string; const Subject, FNAtt: string; const DatFN, UkazatMail: boolean): boolean;
{ AdRcpt := Adresa příjemce nebo '' není-li }
{ NmRcpt := Jméno příjemce nebo '' není-li }
{ Subject := Předmět zprávy }
{ FNAtt := FN s cestou, kde nalezneme soubor co chcem poslat nebo '' není-li soubor }
{ DatFN := true - dá do majlu FN souboru s cestou, false nedá (jen pro FNAtt <> '') }
{ UkazatMail := true - majl před xicht, false - odeslat mlčky }
{Vrací: true - povedlo se, false nepovedlo }
function IIf (const ACnd: boolean; A1, A2: string): string; overload;
begin if ACnd then Result := A1 else Result := A2;
end;
function IIf (const ACnd: boolean; A1, A2: integer): string; overload;
begin if ACnd then Result := A1 else Result := A2;
end;
const RceCrLf = #$0D#$0A; {----- Znaky <CR> + <LF> }
var
MapiMessage: TMapiMessage; MapiRecipDesc: TMapiRecipDesc; MapiFileDesc: TMapiFileDesc; ws: string;
MapiFlags: cardinal; MAPIResult: cardinal;
begin
{----------------------------------------------- Pro MS IE nesmí být v jménu příjemce ',' ani ';' }
NmRcpt := StringReplace (NmRcpt, ',', ' ', [rfReplaceAll]);
NmRcpt := StringReplace (NmRcpt, ';', ' ', [rfReplaceAll]);
MapiRecipDesc.ulReserved := 0;
MapiRecipDesc.ulRecipClass := MAPI_TO;
MapiRecipDesc.lpszName := PChar (IIf (NmRcpt = '', AdRcpt, NmRcpt));
MapiRecipDesc.lpszAddress := PChar (AdRcpt);
MapiRecipDesc.ulEIDSize := 0;
MapiRecipDesc.lpEntryID := nil;
MapiFileDesc.ulReserved := 0;
MapiFileDesc.flFlags := 0;
MapiFileDesc.nPosition := 1;
MapiFileDesc.lpszPathName := PChar (FNAtt);
MapiFileDesc.lpszFileName := nil;
MapiFileDesc.lpFileType := nil;
MapiMessage.ulReserved := 0;
MapiMessage.lpszSubject := PChar (Subject);
MapiMessage.lpszNoteText := PChar (IIf (DatFN and (FNAtt <> ''), 'File ' + FNAtt + RceCrLf + RceCrLf, '') + 'Od: ' + ' Odesílatel');
MapiMessage.lpszMessageType := nil;
MapiMessage.lpszDateReceived := nil;
MapiMessage.lpszConversationID := nil;
MapiMessage.flFlags := 0;
MapiMessage.lpOriginator := nil;
MapiMessage.nRecipCount := IIf ((AdRcpt = '') and (NmRcpt = ''), 0, 1);
MapiMessage.lpRecips := @MapiRecipDesc;
MapiMessage.nFileCount := IIf (FNAtt = '', 0, 1);
MapiMessage.lpFiles := @MapiFileDesc;
MapiFlags := MAPI_LOGON_UI or MAPI_NEW_SESSION; if UkazatMail then MapiFlags := MapiFlags or MAPI_DIALOG;
MAPIResult := MAPISendMail (0, Application.Handle, MapiMessage, MapiFlags, 0);
Result := MapiResult = SUCCESS_SUCCESS;
if not Result then Hlášení nějaké chyby
end;