以前写的一个发邮件的函数,能用就拿去用吧function TSendMailForm.Sendmail(MailList: TStrings; Subject: String; Content: TStrings): Boolean;var MailAddr: String; i: Integer;begin Result := true; try if not FidSmtp.Connected then begin ExchangeData(True); FidSmtp.Connect; end; except //Self.ShowModal; //Sendmail(MailList, Subject, Content); Application.MessageBox('设置错误不能连接到指定的SMTP服务器'+#13+'请重新设置!', '系统提示'); Result := false; end; if FIdSmtp.Connected then begin for i := 0 to MailList.Count - 1 do begin if i = 0 then MailAddr := MailList.Strings else MailAddr := MailAddr + ',' + MailList.Strings; end; FIdMessage.Recipients.EMailAddresses := MailAddr; FIdmessage.Subject := Subject; FIdMessage.Body.Assign(Content); try FidSmtp.Send(FIdmessage); except ON E: Exception Do begin MsgBox(E.Message); Result := false; exit; end; end; MsgBox('发送成功!'); end;end;
有没有一行解决的?比如说下面的代码:ShellExecute(handle,nil,"mailto:zh@163.com?subject=about the program"&body=hello world'nil,nil,sw_shownormal);就一行搞定,但是问题是他界面会有提示,让客户选择,我的意思就是想不要让他出来这个提示,直接就发送了。但是好像用WinExec函数我又不会写啊。还有人可以帮帮我?