打印本文 打印本文 关闭窗口 关闭窗口
直接用WinSock API 发E-mail.
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2543  更新时间:2009/4/23 18:30:24  文章录入:mintao  责任编辑:mintao
>encryptB64(s: string): string;
var
  
hash1: TIdEncoderMIME;
  p: string;
begin
  if 
s <> '''''''' then
  begin
    
hash1 := TIdEncoderMIME.Create(nil);
    p := hash1.Encode(s);
    hash1.Free;
  end;
  Result := p;
end;

end.

//------------------------------------------
// 怎么使用定义好得相关单元
//---------------------------------------------
unit Unit1;

interface

uses
  
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  
TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    
{ Private declarations }
  
public
    
{ Public declarations }
  
end;

var
  
Form1: TForm1;

implementation

{$R *.dfm}

uses
  
SMTP_Connections;

procedure TForm1.Button1Click(Sender: TObject);
var
  
mto, mbody: TStringList;
  MailServer, uname, upass, mFrom, mFromName,
  mToName, Subject: string;
begin
  
mMemo := Memo1; // 定义相关发送服务器
  //..........................
  
MailServer := ''''mail.163.com'''';
  uname := ''''username'''';
  upass := ''''password'''';
  mFrom :=  ''''laolij@163.com;
  mFromName := ''''forename surname'''';
  mToName := '''''''';
  Subject := ''''Your Subject'''';
  //..........................
  
mto := TStringList.Create;
  mbody := TStringList.Create;
  try
    
mto.Add(''''anybody@xyz.net'''');
    mbody.Add(''''测试邮件'''');
    //发送.................
    
_authSendMail(MailServer, uname, upass, mFrom, mFromName, mToName, Subject, mto, mbody);
    //..........................
  
finally
    
mto.Free;
    mbody.Free;
  end;
end;

end.

上一页  [1] [2] [3] 

打印本文 打印本文 关闭窗口 关闭窗口