{"id":487,"date":"2009-06-24T20:17:00","date_gmt":"2009-06-24T12:17:00","guid":{"rendered":""},"modified":"2013-11-17T17:25:06","modified_gmt":"2013-11-17T09:25:06","slug":"delphi%e5%8f%91%e9%82%ae%e4%bb%b6%e7%a8%8b%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/487.html","title":{"rendered":"Delphi\u53d1\u90ae\u4ef6\u7a0b\u5e8f"},"content":{"rendered":"<pre class=\"brush: delphi; title: ; notranslate\" title=\"\">\r\nunit Unit1;\r\n\r\ninterface\r\n\r\nuses\r\n  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,\r\n  Dialogs, StdCtrls, IdMessage, IdBaseComponent, IdComponent, IdTCPConnection,\r\n  IdTCPClient, IdExplicitTLSClientServerBase, IdMessageClient, IdSMTPBase,\r\n  IdSMTP;\r\n\r\ntype\r\n  TForm1 = class(TForm)\r\n    Edit1: TEdit;\r\n    Button1: TButton;\r\n    Label1: TLabel;\r\n    Memo1: TMemo;\r\n    IdSMTP1: TIdSMTP;\r\n    IdMessage1: TIdMessage;\r\n    procedure Button1Click(Sender: TObject);\r\n  private\r\n    { Private declarations }\r\n  public\r\n    { Public declarations }\r\n  end;\r\n\r\nvar\r\n  Form1: TForm1;\r\n\r\nimplementation\r\n\r\n{$R *.dfm}\r\n\r\nprocedure TForm1.Button1Click(Sender: TObject);\r\nbegin\r\nif trim(edit1.Text)&lt;&gt;'' then\r\nbegin\r\n\/\/\u5efa\u7acb\u8fde\u63a5\r\n  idSMTP1.Username:='\u53f7\u78011@qq.com'; \/\/\u670d\u52a1\u5668\u4e0a\u7684\u7528\u6237\u540d\r\n  idSMTP1.Password:='\u53f7\u78011\u7684\u5bc6\u7801';       \/\/\u670d\u52a1\u5668\u4e0a\u7684\u5bc6\u7801\r\n  idSMTP1.Host:='smtp.qq.com';          \/\/\u670d\u52a1\u5668SMTP\u5730\u5740\r\n  idSMTP1.Port:=25;                     \/\/\u670d\u52a1\u5668\u7aef\u53e3\r\n  try\r\n   idSMTP1.Connect;                      \/\/\u5efa\u7acb\u8fde\u63a5\r\n  except\r\n    Showmessage('\u8fde\u63a5SMTP\u670d\u52a1\u5668\u5931\u8d25!');\r\n    Exit;\r\n  end;\r\n\r\n\/\/\u53d1\u90ae\u4ef6\r\ntry\r\n  idMessage1.Body.Clear;\r\n  idMessage1.Body.assign(memo1.Lines);      \/\/\u90ae\u4ef6\u6b63\u6587\u4ef6\u5185\u5bb9\r\n  idMessage1.From.Address:=\u53f7\u78011';     \/\/\u53d1\u4ef6\u4eba\u5730\u5740\r\n  idMessage1.Recipients.EMailAddresses:=edit1.Text;\/\/\u6536\u4ef6\u4eba\u5730\u5740\r\n  idMessage1.Subject:='Email From Zaitian';        \/\/\u90ae\u4ef6\u6807\u9898\r\n  idMessage1.Priority:=mpHigh;                     \/\/\u4f18\u5148\u7ea7\uff0cmphigh\u4e3a\u6700\u9ad8\u7ea7\u3002\r\n  idSMTP1.Send(idMessage1);\r\nfinally\r\n  showmessage('\u60a8\u7684\u4fe1\u4ef6\u5df2\u6210\u529f\u53d1\u9001');\r\n  idSMTP1.Disconnect;\r\nend;\r\n\r\nend;\r\n\r\nend;\r\n\r\nend.\r\n<\/pre>\n<p>\u6709\u4e00\u4e2a\u9057\u61be\uff0c\u5728D2009\u4e0b\u7f16\u8bd1\u8fd0\u884c\uff0c\u5982\u679c\u90ae\u4ef6\u7684\u4e3b\u9898\u4e3a\u6c49\u5b57\u7684\u8bdd\uff0c\u90a3\u4e48\u53d1\u51fa\u53bb\u7684\u90ae\u4ef6\u7684\u4e3b\u9898\u5c06\u4f1a\u662f\u4e71\u7801\uff0c\u4e0d\u77e5\u9053\u600e\u4e48\u624d\u4f1a\u4e0d\u662f\u4e71\u7801\uff0c\u53ef\u80fd\u662fD2009\u7684\u4e00\u4e2aBUG\u5427\uff0c\u5982\u679c\u54ea\u4f4d\u4ec1\u5144\u77e5\u9053\uff0c\u8bf7\u544a\u77e5\uff0c\u8c22\u8c22<\/p>\n","protected":false},"excerpt":{"rendered":"<p>unit Unit1; interface uses Windows, Messages, SysUtils, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-487","post","type-post","status-publish","format-standard","hentry","category-code_related"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/487","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=487"}],"version-history":[{"count":1,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/487\/revisions"}],"predecessor-version":[{"id":4741,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/487\/revisions\/4741"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=487"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=487"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=487"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}