ITPub博客

首页 > 应用开发 > IT综合 > Delphi6利用WebService 编写 SendEMail程序 (转)

Delphi6利用WebService 编写 SendEMail程序 (转)

原创 IT综合 作者:worldblog 时间:2007-12-09 09:32:28 0 删除 编辑
Delphi6利用WebService 编写 SendEMail程序 (转)[@more@]microsoft FrontPage 5.0">

 到http://www.xmethods.com

就会看到一个Delphi做的服务器程序. Send an EMail

 


 

有如下描述:

我们下载程序接口:

点WSDL URL连接

另存为名为IemailService.wsdl到你的程序相同目录.

导入程序接口:

然后会生成Unit2单元.

Unit Unit2;

interface

uses Types, XSBuiltIns;
type

  IEmailService = interface(IInvokable)
  ['{839561db-8AFE-43B8-81EB-5505C873EC8F}']
  function sendmail(const ToAddress: WideString; const FromAddress: WideString; const ASubject: WideString; const MsgBody: WideString): Integer;  stdcall;
  end;


implementation

uses InvokeRegistry;

initialization
  InvRegistry.RegisterInterface(TypeInfo(IEmailService), '', '');

end.

 

 

选择刚才保存的wsdl文件给HTTPRIO1.WSDLLaction属性

在Unit1中运行编程

unit Unit1;

interface

uses
  windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,  Rio, SOApHTTPClient, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
  Button1: TButton;
  HTTPRIO1: THTTPRIO;
  LabeledEdit1: TLabeledEdit;
  LabeledEdit2: TLabeledEdit;
  LabeledEdit3: TLabeledEdit;
  Memo1: TMemo;
  procedure Button1Click(Sender: Tobject);
  private
  { Private declarations }
  public
  { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;  /////////////

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  if (HTTPRIO1 as IEmailService).SendMail
  (LabeledEdit1.Text,
  LabeledEdit2.Text,
  LabeledEdit3.Text,
  Memo1.Text
  ) = 0 then
  ShowMessage('Send Success!');
end;

end.

可以发邮件了,很方便也很简单.


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-990270/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    6241
  • 访问量
    2406178