Delphi6 writes Sendemail programs with WebService

zhaozj2021-02-08  211

To http://www.xmethods.com

I will see a server program made by Delphi. Send An Email

There is a description as follows:

We download the program interface:

Point WSDL URL connection

Save as named IEmailService.wsdl to your program is the same directory.

Import program interface:

The Unit2 unit is then generated.

Unit unit2;

Interface

Uses type, 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 (TypeIlService), '', '');

End.

Select the WSDL file just saved to httprio1.wsdllaction properties

Run programming in 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.

It can be sent, which is very convenient.

转载请注明原文地址:https://www.9cbs.com/read-2483.html

New Post(0)