请教如何在delphi中单击按钮后调用本地邮箱发邮件. 请教如何在delphi中单击按钮后调用本地邮箱发邮件. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 uses shellApi;Shellexecute(0, nil, 'mailto:[email protected]', nil, nil, sw_ShowNormal); 是成功调出了Outlook Expree,能不能更方便点,就是不弹出这个,在程序里定义邮件标题和内容,当用户一点Botton时就自动发出去. 用indy Clients标签中的IdSMTP和indy Misc标签里的IdMessage,代码如下://-----问题是不知如何获取本机默认的邮件客户端的用户名去发这个邮件,//-----各位一起研究一下.unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, IdComponent, IdTCPConnection, IdTCPClient, IdMessageClient, IdSMTP, IdBaseComponent, IdMessage, StdCtrls;type TForm1 = class(TForm) Button1: TButton; MailMessage: TIdMessage; Mail: TIdSMTP; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);begin if Mail.Connected then Mail.Disconnect; Mail.Username:='mail_username'; Mail.Password:='mail_password'; Mail.Host:='220.181.12.15'; Mail.Port:=25; Mail.AuthenticationType:=atLogin; MailMessage.Subject:='Hello Delphi'; MailMessage.Body.Text:='Hello Delphi!!'; MailMessage.From.Name:=''mail_username'; MailMessage.From.Address:='[email protected]'; MailMessage.ReplyTo.EMailAddresses:='[email protected]'; MailMessage.Priority:=TidMessagePriority(1); MailMessage.Recipients.EMailAddresses:='[email protected]'; MailMessage.From.Address:='[email protected]'; try mail.Connect; mail.Authenticate; mail.Send(MailMessage); finally mail.Disconnect; end; end;end. 用delphi自己的idsmtp控件就可以实现,类似下面代码var mailaddress:TIdEMailAddressItem; i:integer;begin try if FIdSMTP.Connected then FIdSMTP.Disconnect; FIdMessage.charset:='GB2312_CHARSET'; FIdMessage.ContentType:='text/html'; FIdSMTP.Host :='邮件服务器'; FIdSMTP.AuthenticationType := atLogin; FIdSMTP.Username := '用户名'; FIdSMTP.Password := '密码'; FIdSMTP.Connect; if FIdSMTP.Authenticate then begin //发信人 FIdMessage.From.Address := FFromAddress; FIdMessage.From.Name := FFromUser; FIdMessage.Recipients.Clear; FIdMessage.ReplyTo.Clear; for i:=0 to FToAddress.Count-1 do begin mailaddress := FIdMessage.Recipients.Add; mailaddress.Address := FToAddress[i]; end; mailaddress := FIdMessage.ReplyTo.Add; mailaddress.Address := '回复地址'; //主题 FIdMessage.subject:= FTopic; //信件内容 with FIdMessage.Body do begin Clear; Add('<Html>'); Add('<style type="text/css">'); Add('<!--'); Add('.STYLE7 {'); Add(' font-size: 24px;'); Add(' font-family: "宋体";'); Add(' font-weight: bold;'); Add('}'); Add('.STYLE9 {color: #0066FF}'); Add('.STYLE23 {font-weight: bold; font-size: 13pt; }'); Add('.STYLE24 {color: #FF0000}'); Add('.STYLE25 {'); Add(' color: #0000FF;'); Add(' font-weight: bold;'); Add('} '); Add('.STYLE26 {'); Add(' color: #993300;'); Add(' font-weight: bold;'); Add('}'); Add('.STYLE27 {color: #993300}'); Add('-->'); Add('</style>'); Add('<Body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">'); Add('<Font Size=3>'); Add('<BR>'); Add(' <span class="STYLE23">内容:'+FContent[0]+'</span><BR>'); Add('</Font>'); Add('</Body>'); Add('</Html>'); end; //发送 try FIdSMTP.Send(FIdMessage); except Result := false; end; end else begin result := false; end; finally if FIdSMTP.Connected then FIdSMTP.Disconnect; end; 能不能用hide的方式打开Outlook Expree,然后,找到相应的Outlook Expree窗口内的句柄,把标题和内容发消息进去? 如果纯粹只是发一封邮件,用IDSMTP就好,调用OUTLOOK,现在很多人都不配置这个 为什么我的deiphi会在将TQuery的Action属性设为true时,delphi会自动关闭?急 QuickRep+QRImage 图片打印,高分相送! 快捷键问题:Ctrl+X不好用了 怎样进行SQLServer2000客户端精简安装! 快捷键问题 推荐一个申请免费域名的网址和方法 ★★★ 如何实现矢量字体 ★★★ 急!!!关于调用word,excel等自动化对象!!! Js调用delphiOCX里的函数,报对象不支持"Test"属性或方法 奇哉怪也??????????? 移动硬盘失而复得,散分 手动向stringgrid中输入数据,怎样保存到数据库?给个实例
shellApi;
Shellexecute(0, nil, 'mailto:[email protected]', nil, nil, sw_ShowNormal);
//-----各位一起研究一下.unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdComponent, IdTCPConnection, IdTCPClient, IdMessageClient,
IdSMTP, IdBaseComponent, IdMessage, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
MailMessage: TIdMessage;
Mail: TIdSMTP;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
if Mail.Connected then Mail.Disconnect;
Mail.Username:='mail_username';
Mail.Password:='mail_password';
Mail.Host:='220.181.12.15';
Mail.Port:=25;
Mail.AuthenticationType:=atLogin;
MailMessage.Subject:='Hello Delphi';
MailMessage.Body.Text:='Hello Delphi!!';
MailMessage.From.Name:=''mail_username';
MailMessage.From.Address:='[email protected]';
MailMessage.ReplyTo.EMailAddresses:='[email protected]';
MailMessage.Priority:=TidMessagePriority(1);
MailMessage.Recipients.EMailAddresses:='[email protected]';
MailMessage.From.Address:='[email protected]';
try
mail.Connect;
mail.Authenticate;
mail.Send(MailMessage);
finally
mail.Disconnect;
end;
end;end.
mailaddress:TIdEMailAddressItem;
i:integer;
begin
try
if FIdSMTP.Connected then
FIdSMTP.Disconnect;
FIdMessage.charset:='GB2312_CHARSET';
FIdMessage.ContentType:='text/html';
FIdSMTP.Host :='邮件服务器';
FIdSMTP.AuthenticationType := atLogin;
FIdSMTP.Username := '用户名';
FIdSMTP.Password := '密码';
FIdSMTP.Connect;
if FIdSMTP.Authenticate then
begin
//发信人
FIdMessage.From.Address := FFromAddress;
FIdMessage.From.Name := FFromUser;
FIdMessage.Recipients.Clear;
FIdMessage.ReplyTo.Clear;
for i:=0 to FToAddress.Count-1 do
begin
mailaddress := FIdMessage.Recipients.Add;
mailaddress.Address := FToAddress[i];
end;
mailaddress := FIdMessage.ReplyTo.Add;
mailaddress.Address := '回复地址';
//主题
FIdMessage.subject:= FTopic;
//信件内容
with FIdMessage.Body do
begin
Clear;
Add('<Html>');
Add('<style type="text/css">');
Add('<!--');
Add('.STYLE7 {');
Add(' font-size: 24px;');
Add(' font-family: "宋体";');
Add(' font-weight: bold;');
Add('}');
Add('.STYLE9 {color: #0066FF}');
Add('.STYLE23 {font-weight: bold; font-size: 13pt; }');
Add('.STYLE24 {color: #FF0000}');
Add('.STYLE25 {');
Add(' color: #0000FF;');
Add(' font-weight: bold;');
Add('} ');
Add('.STYLE26 {');
Add(' color: #993300;');
Add(' font-weight: bold;');
Add('}');
Add('.STYLE27 {color: #993300}');
Add('-->');
Add('</style>');
Add('<Body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">');
Add('<Font Size=3>');
Add('<BR>');
Add(' <span class="STYLE23">内容:'+FContent[0]+'</span><BR>');
Add('</Font>');
Add('</Body>');
Add('</Html>');
end;
//发送
try
FIdSMTP.Send(FIdMessage);
except
Result := false;
end;
end else
begin
result := false;
end;
finally
if FIdSMTP.Connected then
FIdSMTP.Disconnect;
end;
能不能用hide的方式打开Outlook Expree,然后,找到相应的Outlook Expree窗口内的句柄,把标题和内容发消息进去?