想用OLE2方式使用OUTLOOK,请问: 新邮件的收件人啊、题目、正文啊,我想从数据库里拿数据出来填写,不知道用的是什么属性?请大虾赐教。我分数不多,请原谅。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用这个函数function SendEmail(Handle: THandle; Mail: TStrings): Cardinal;//调用MAPI发送Emailtype 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'] := ReportName; //以下内容 mail.Values['body'] := ''; //以下附件 mail.Values['attachment0'] := ReportAllName; SendEmail(Application.Handle, mail); finally mail.Free; end;end; 谢谢楼上大虾!!!谢谢您的程序!!!不过,要实现正文的内容,甚至缩排、大小写,如何是好?是否要弄个WORD文档进来?如何是好?偶菜晕死 不知道算不算DBGRID的一个BUG 渴求算法,高手指点 如何用DELPHI终止系统某个进程,急 如何动态的添加Delphi的组件? 关于hook的问题,解决200分全给! ListView问题,大侠帮忙阿 动态加载FRAMES的时候,如何给FRAMES里的元素赋值?100分 如何关闭数据库? toolbar中的toolbutton上怎么显示文字和图标 用delphi做3D虚拟世界一类的的软件,有例子或者源代码嘛?----谢谢 一个关于TXMLDocument的问题 关于瘦客户端程序通过注册表查找应用程序服务器的疑问,请高手指点,谢谢~!
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'] := ReportName;
//以下内容
mail.Values['body'] := '';
//以下附件
mail.Values['attachment0'] := ReportAllName; SendEmail(Application.Handle, mail);
finally
mail.Free;
end;
end;
谢谢您的程序!!!
不过,要实现正文的内容,甚至缩排、大小写,如何是好?
是否要弄个WORD文档进来?如何是好?偶菜晕死