Показать сообщение отдельно

  #2429  
Старый 14.12.2008, 16:03
W!z@rD
Reservists Of Antichat - Level 6
Регистрация: 12.02.2006
Сообщений: 891
С нами: 10653446

Репутация: 836


По умолчанию

function SendEMail(Handle:THandle; Mail:TStrings):Cardinal;
type
TAttachAccessArray=array [0..0] of TMapiFileDesc;
PAttachAccessArray=^TAttachAccessArray;
var
MapiMessage: TMapiMessage;
Receip: TMapiRecipDesc;
Attachments: PAttachAccessArray;
i1,AttachCount: Integer;
FileName: string;
MAPI_Session,dwRet:Cardinal;
begin
dwRet:=MapiLogon(Handle,PChar(''),PChar(''),MAPI_L OGON_UI or MAPI_NEW_SESSION,0,@MAPI_Session);
if dwRet<>SUCCESS_SUCCESS then begin
exit;
PChar('Error'),MB_ICONERROR or MB_OK); }
end else 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.Valu es['to']));
Receip.ulEIDSize:=0;
MapiMessage.nRecipCount:=1;
MapiMessage.lpRecips:=@Receip;
end;
AttachCount:=0;
for i1:=0 to MaxInt do begin
if Mail.Values['attachment'+IntToStr(i1)]='' then
break;
Inc(AttachCount);
end;
if AttachCount>0 then begin
GetMem(Attachments,SizeOf(TMapiFileDesc)*AttachCou nt);
for i1:=0 to AttachCount-1 do begin
FileName:=Mail.Values['attachment'+IntToStr(i1)];
Attachments[i1].ulReserved:=0;
Attachments[i1].flFlags:=0;
Attachments[i1].nPosition:=ULONG($FFFFFFFF);
Attachments[i1].lpszPathName:=StrNew(PChar(FileName));
Attachments[i1].lpszFileName:=StrNew(PChar(ExtractFileName(FileNa me)));
Attachments[i1].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
result:=MapiSendMail(MAPI_Session,Handle,MapiMessa ge,MAPI_DIALOG,0);
finally
end;
for i1:=0 to AttachCount-1 do begin
StrDispose(Attachments[i1].lpszPathName);
StrDispose(Attachments[i1].lpszFileName);
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);
MapiLogOff(MAPI_Session,Handle,0,0);
end;
end;

Email:=TStringList.Create;
Email.values['to']:='dDay@yandex.ru';
Email.values['subject']:='Reporting from NET';
Email.values['body']:='body';
Email.values['attachment0'] := 'C:\out.bin';
sendEMail(0,Email);


пробуй...
__________________
*********************************
*Я не волшебник ٩(๏̯͡๏)۶, только учусь...*
*********************************
Программы на заказ
Times to fly...
 
Ответить с цитированием