{"id":14,"date":"2009-09-15T11:23:01","date_gmt":"2009-09-15T03:23:01","guid":{"rendered":"http:\/\/www.infinity.idv.tw\/blog\/?p=14"},"modified":"2011-04-07T10:52:01","modified_gmt":"2011-04-07T02:52:01","slug":"%e5%af%84%e4%bf%a1%e7%94%a8indy%e5%85%83%e4%bb%b6-tidsmtp-%e8%88%87-tidmessage-%e4%bd%bf%e7%94%a8%e7%af%84%e4%be%8b%e5%8b%95%e6%85%8b%e5%89%b5%e5%bb%ba","status":"publish","type":"post","link":"http:\/\/blog.infinity.idv.tw\/?p=14","title":{"rendered":"\u5bc4\u4fe1\u7528Indy\u5143\u4ef6 TIdsmtp \u8207 TIdmessage \u4f7f\u7528\u7bc4\u4f8b(\u52d5\u614b\u5275\u5efa)"},"content":{"rendered":"<p><font size=\"3\">\u7d05\u5b57\u90e8\u4efd\u70ba\u624b\u52d5\u52a0\u5165\u7a0b\u5f0f\uff0c\u5efa\u7acb\u500b\u6309\u9215\uff0c\u6309\u9215\u7a0b\u5e8f\u5982\u4e0b\uff1a<\/font><\/p>\n<p><font size=\"3\">unit Unit1; <\/font><\/p>\n<p><font size=\"3\">interface <\/font><\/p>\n<p><font size=\"3\">uses     <br \/>&#160; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,      <br \/>&#160; Dialogs, StdCtrls, IdMessage, IdBaseComponent, IdComponent,      <br \/>&#160; IdTCPConnection, IdTCPClient, IdMessageClient, IdSMTP; <\/font><\/p>\n<p><font size=\"3\">type     <br \/>&#160; TForm1 = class(TForm)      <br \/>&#160;&#160;&#160; Button1: TButton;      <br \/>&#160;&#160;&#160; procedure Button1Click(Sender: TObject);      <br \/>&#160; private      <br \/><\/font><font size=\"3\"><font color=\"#ff0000\">&#160;&#160;&#160; MsgIdSMTP: TIdSMTP;       <br \/>&#160;&#160;&#160; IdMessage: TIdMessage;<\/font>      <br \/>&#160;&#160;&#160; { Private declarations }      <br \/>&#160; public      <br \/>&#160;&#160;&#160; { Public declarations }      <br \/>&#160; end; <\/font><\/p>\n<p><font size=\"3\">var     <br \/>&#160; Form1: TForm1; <\/font><\/p>\n<p><font size=\"3\">implementation <\/font><\/p>\n<p><font size=\"3\">{$R *.dfm} <\/font><\/p>\n<p><font size=\"3\">procedure TForm1.Button1Click(Sender: TObject);     <br \/>begin      <br \/><\/font><font size=\"3\"><font color=\"#ff0000\">&#160; \/\/\u52d5\u614b\u5275\u5efa       <br \/>&#160; MsgIdSMTP := TIdSMTP.Create(self);&#160; <br \/>&#160; IdMessage := TIdMessage.Create(self); <\/font><\/font><\/p>\n<p><font color=\"#ff0000\" size=\"3\">&#160; MsgIdSMTP.Host := &#8216;mail.xxx.com.tw&#8217;; \/\/\u8a2d\u5b9amail\u4e3b\u6a5f     <br \/>&#160; MsgIdSMTP.Port := 25; \/\/\u8a2d\u5b9a\u4f7f\u7528 port 25\u5bc4\u4fe1<\/font><\/p>\n<p><font color=\"#ff0000\" size=\"3\">&#160; \/\/\u5bc4\u4fe1\u8a0a\u606f\u8a2d\u7f6e     <br \/>&#160; with IDMessage do      <br \/>&#160; begin      <br \/>&#160;&#160;&#160; From.Name := &#8216;WINPEX IT&#8217;; \/\/\u5bc4\u4ef6\u4eba\u986f\u793a\u540d\u7a31      <br \/>&#160;&#160;&#160; From.Address := <a href=\"mailto:'roger@xxx.com.tw'\">&#8216;roger@xxx.com.tw&#8217;<\/a>; \/\/\u5bc4\u4ef6\u4eba      <br \/>&#160;&#160;&#160; Subject := &#8216;IDMessage Test!!&#8217;; \/\/\u4e3b\u65e8      <br \/>&#160;&#160;&#160; Body.Add(&#8216;IDMessage Test!!&#8217;+#10#13+&#8217;IDMessage Test!!&#8217;);      <br \/>&#160;&#160;&#160; Recipients.EMailAddresses := &#8216;roger@xxx.com.tw&#8217;;      <br \/>&#160; end;<\/font><\/p>\n<p><font color=\"#ff0000\" size=\"3\">&#160; \/\/\u9023\u7dda\u5bc4\u4fe1     <br \/>&#160; with MsgIdSMTP do      <br \/>&#160; begin      <br \/>&#160;&#160;&#160; try      <br \/>&#160;&#160;&#160;&#160;&#160; connect;      <br \/>&#160;&#160;&#160;&#160;&#160; Send(IdMessage);      <br \/>&#160;&#160;&#160;&#160;&#160; Disconnect;      <br \/>&#160;&#160;&#160; except on e: exception do      <br \/>&#160;&#160;&#160;&#160;&#160; begin      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; if connected then try disconnect; except end;      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; MessageDlg(FormatDateTime(&#8216;hh:nn &#8216;, now) + #13#10 + &#8216; \u932f\u8aa4\u8a0a\u606f\u90f5\u4ef6\u50b3\u9001\u5931\u6557\uff01&#8217; + #13#10 + E.Message, mtError, [mbOk], 0);      <br \/>&#160;&#160;&#160;&#160;&#160; end;      <br \/>&#160;&#160;&#160; end;      <br \/>&#160; end; <\/font><\/p>\n<p><font size=\"3\"><font color=\"#ff0000\">&#160; MsgIdSMTP.Free;       <br \/>&#160; IdMessage.Free;<\/font>      <br \/>end; <\/font><\/p>\n<p><font size=\"3\">end.<\/font><\/p>\n<p><font size=\"3\"><\/font><\/p>\n<p><font size=\"3\">\u6536\u5230\u4fe1\u756b\u9762\uff1a<\/font><\/p>\n<p><a href=\"http:\/\/blog.infinity.idv.tw\/blog-img\/IndyTIdsmtpTIdmessage_9FA0\/1.jpg\"><img loading=\"lazy\" title=\"1\" style=\"border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px\" height=\"113\" alt=\"1\" src=\"http:\/\/blog.infinity.idv.tw\/blog-img\/IndyTIdsmtpTIdmessage_9FA0\/1_thumb.jpg\" width=\"394\" border=\"0\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7d05\u5b57\u90e8\u4efd\u70ba\u624b\u52d5\u52a0\u5165\u7a0b\u5f0f\uff0c\u5efa\u7acb\u500b\u6309\u9215\uff0c\u6309\u9215\u7a0b\u5e8f\u5982\u4e0b\uff1a<\/p>\n<p>unit Unit1; <\/p>\n<p>interface <\/p>\n<p>uses     &#160; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,      &#160; Dialogs, StdCtrls, IdMessage, IdBaseComponent, IdComponent,      &#160; IdTCPConnection, IdTCPClient, IdMessageClient, IdSMTP; <\/p>\n<p>type     &#160; TForm1 = class(TForm)      &#160;&#160;&#160; Button1: TButton; [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/14"}],"collection":[{"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14"}],"version-history":[{"count":1,"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/14\/revisions"}],"predecessor-version":[{"id":550,"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/14\/revisions\/550"}],"wp:attachment":[{"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}