当前位置:主页>销售管理软件> 列表

如何用API发邮件~~~~~! 找库存管理

库存管理软件版1楼: 我看过别人写的不过看不明白,谁能给我一下带有说明的!(中文)

2楼: function SendEmail(Handle: THandle; Mail: TStrings): Cardinal;
//调用MAPI发送Email
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'']));



Result := MapiSendMail(0, Handle, MapiMessage, MAPI_DIALOG*Ord(Handle <> 0) OR MAPI_LOGON_UI OR MAPI_NEW_SESSION, 0);

for iCount := 0 to (AttachCount - 1) do begin
strDispose(Attachments[iCount].lpszPathName);
strDispose(Attachments[iCount].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);
end;

procedure TFrmPrintReport.FlatButton3Click(Sender: TObject);
var
mail : TStringList;
begin
mail := TStringList.Create;
try
//以下邮箱
mail.Values[''to''] := EmailAdderss;
//以下主题
mail.Values[''subject''] := ''主题...'';
//以下内容
mail.Values[''body''] := ''内容.....'';
//以下附件
mail.Values[''attachment0''] :=''c:\test.txt'' ;

SendEmail(Application.Handle, mail);
finally
mail.Free;
end;


end; 如库存管理

3楼: 不行,

4楼: 还没有中文呢!

5楼: 1

6楼: 用ShellExecute来发送邮件就可以了
use ShellApi
procedure shndmail;
var s:string;
begin
s:=''mailto abc2com.cn?subject=Hello&Body=你好'';
ShellExecute(0,''open'',pchar(s),nil,nil,WS_SHOWNORMAL;
end;

库存管理软件版7楼: procedure shndmail;
var s:string;
begin
s:=''mailto abc2com.cn?subject=Hello&Body=你好'';
ShellExecute(0,''open'',pchar(s),nil,nil,SW_SHOWNORMAL;
end;

8楼: 用控件的我就有,现在的,一个商业软件在用,和发短信的,要找我。对了发短信的要用硬件,同件用控件就行。