делаю так, но неработает и ошибки не выдает
| Код | unit Unit1;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,Mapi, StdCtrls;
type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.DFM}
function SendMail(const From, Dest, Subject, Text, FileName: PChar; Outlook: boolean):Integer; var Message: TMapiMessage; Recipient, Sender: TMapiRecipDesc; File_Attachment: TMapiFileDesc;
function MakeMessage: TMapiMessage; begin FillChar(Sender, SizeOf(Sender), 0); Sender.ulRecipClass := MAPI_ORIG; Sender.lpszAddress := From;
FillChar(Recipient, SizeOf(Recipient), 0); Recipient.ulRecipClass := MAPI_TO; Recipient.lpszAddress := Dest;
FillChar(File_Attachment, SizeOf(File_Attachment), 0); File_Attachment.nPosition := Cardinal(-1); File_Attachment.lpszPathName := FileName;
FillChar(Result, SizeOf(Result), 0); with Message do begin lpszSubject := Subject; lpszNoteText := Text; lpOriginator := @Sender; nRecipCount := 1; lpRecips := @Recipient; nFileCount := 1; lpFiles := @File_Attachment; end; end;
var SM: TFNMapiSendMail; MAPIModule: HModule; MAPI_FLAG: Cardinal; begin if Outlook then MAPI_FLAG:=MAPI_DIALOG else MAPI_FLAG:=0; MAPIModule := LoadLibrary(PChar(MAPIDLL)); if MAPIModule = 0 then Result := -1 else try @SM := GetProcAddress(MAPIModule, 'MAPISendMail'); if @SM <> nil then begin MakeMessage; Result := SM(0, Application.Handle, Message, MAPI_FLAG, 0); end else Result := 1; finally FreeLibrary(MAPIModule); end; end;
procedure TForm1.Button1Click(Sender: TObject); Var From,Dest,Subject,Text,FileName:String; TheBat:Boolean;
begin From:='NANV@cherhleb.ru'; // - îò êîãî Dest:='NANV@cherhleb.ru'; // - êîìó Subject:='Ïðèâåò êàê æèçíü'; // - òåìà Text:='Ïðèâåò ïîøëè ïèòü ïèâî!!!'; // - òåêñò ïèñüìà FileName:='C:\1.xls'; // - ïóòü ê âëîæåíèþ (åñëè '', òî ñîîòâåòñòâåííî íè÷åãî è íå âêëàäûâàåì) Thebat:=False; // - ïîêàçûâàòü èëè íåò ïèñüìî ïåðåä îòïðàâêîé (â òâî¸ì ñëó÷àå False) SendMail(Pchar(From),Pchar(Dest),Pchar(Subject),Pchar(Text),Pchar(FileName),TheBat); end;
end.
|
помогите, пожалуйста |