Отправка письма

Советы » E-mail » Отправка письма

Uses

.., Mapi;
Function

SendMail(const From, Dest, Subject, Text, FileName: PChar): 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 := ULONG(-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;
begin


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, 0, Message, 0, 0); end else Result := 1;
finally
FreeLibrary(MAPIModule); end;
end

;

Другое по теме:

Категории

Статьи

Советы

Copyright © 2022 - All Rights Reserved - www.delphirus.com