Hai, everyone, I am a dream, say this should be a second post. This time I brought a letter to everyone. I don't know if you like everyone. If you are not satisfied, don't tighten, you will be a dream. OK, if you think it is ok, please don't forget to dream for a vote, the little dream is here to say thank you. ^ _ ^
OK, or the old saying, transfer to the topic, now we will do a letter.
First we should add the following components in the project.
Caption component associated with the component name Label1 mail server address: Edit1Label2 account name: Edit2Label3 port number: Edit3Label4 groups receiving server address: Edit4Label5 recipients name: ComboBox1Label6 mail Subject Information: Edit5Label7 letter to be sent: Edit6Label8 mail attachments path: ListBox1Label9 letter display Information Name: Edit8Label10 Sender Email Address: Edit9checkbox1 Punction Sending Source Button1 Start Send Xinton2 Read Dictionary File Button3 ... Edit6Button4 Add / ListBoxButton5 Clear ListBoxPanel1 Panel2 Statusbar1 OpenDialog1 NMSMTP1 ListBox1
Ok, when we finished all the above components, and after the position, we can copy the following code to the Delphi code editing column.
Unit Unit1; InterfaceUses Windows, Messages, Sysutils, Classes, Graphics, Controls, Forms, Dialogs, Stdctrls, Psock, NMSMTP, ExtCtrls, ComCtrls
TYPE TFORM1 = Class (TFORM) NMSMTP1: TNMSMTP; Panel1: TPANEL; label9: TLabel; Edit8: TEDIT; Edit9: Tedit; label10: TLABEL; label6: TLabel; label7: TLABEL; label8: tlabel; edit6: tedit; edit5: tedit ; Button3: TButton; Button4: TButton; Panel2: TPanel; Label1: TLabel; Label4: TLabel; Edit4: TEdit; ComboBox1: TComboBox; Button1: TButton; Button2: TButton; CheckBox1: TCheckBox; Label5: TLabel; Edit2: TEdit; Label2 : TLabel; Label3: TLabel; Edit3: TEdit; StatusBar1: TStatusBar; OpenDialog1: TOpenDialog; ListBox1: TListBox; Edit1: TEdit; Button5: TButton; procedure Button3Click (Sender: TObject); procedure Button4Click (Sender: TObject); procedure Button2Click ( Sender: TObject); procedure NMSMTP1Success (Sender: TObject); procedure NMSMTP1Failure (Sender: TObject); procedure SendNextmail (var datteinc: integer); procedure Button1Click (Sender: TObject); procedure FormCloseQuery (Sender: TObject; var CanClose: Boolean); procedure NMSMTP1ConnectionFailed (Sender: TObject); procedure NMSMTP1ConnectionRequired (var Handled: Boolean); procedure NMSMTP1InvalidHost (var Handled: Boolean); procedure FormCreate (Sender: TObject); procedure Edit1Change (Sender: TObject); procedure Edit2Change (Sender: TObject); procedure Button5Click (Sender: TObject); procedure Edit8KeyDown (Sender: TObject; var Key: Word; Shift: TShiftState); procedure Edit9KeyDown (Sender: TObject; var Key: Word; Shift: TShiftState); Procedure Edit6keyDown (Sender: Tobject; Var Key: Word; Shift: TshiftState); Procedure Edit5keyDown (Sender: Tobject; Var Key: Word; Shift: TshiftState);
procedure Edit1KeyDown (Sender: TObject; var Key: Word; Shift: TShiftState); procedure Edit2KeyDown (Sender: TObject; var Key: Word; Shift: TShiftState); procedure Edit4KeyDown (Sender: TObject; var Key: Word; Shift: TShiftState) ; procedure ComboBox1KeyDown (Sender: TObject; var Key: Word; Shift: TShiftState); procedure helpshow; procedure FormKeyDown (Sender: TObject; var Key: Word; Shift: TShiftState); private {Private declarations} public {public declarations} end; Var Form1: TFORM1; SendsuC, Sendfal, Cursennum, Totaco: Integer; Connal, Startsen: Boolean; Implementation
{$ R * .dfm} procedure tform1.helpshow; beginshowMessage (# 13 '┏┏━━━━━━━━━━━━━━━━━━━━━━━━━━━ ┓ ' # 13 ' When you use this sender to send a letter, you should finish the following: ' # 13 ' ┣┣━━━━━━━━━━━━━━━ ━━━━━━━━━━━━━┫┫┫ ' # 13 ' 1 Enter the address of the recipient group in the recipient address bar ' # 13 ' Extraction: xxx@yyy.nnn should be filled in: YYY.NNN ' # 13 ' # 13 2 Because this sender is only an example, there is no exhaustive letter function, So you should ' # 13 ' 收 收 收 收 收 收 收 文件 文件 文件 文件 文件 文件 文件 举 文件 举 举 举 举 举 举 举 举 举 举 举 举 举 举 举 举 举 举 举One, press the Enter key once) ' # 13 ' ' # 13 ' ┣┣━━━━━━━━━━━━━━━━━━━━━━ ━━━━┫┫ ' # 13 '. "If you use it to do some unhanective things, ' # 13 ' everything is responsible. Own ' # 13 '┗┗━━━━━━━━━━━━━━━━━━┛┛┛━━━━━━┛┛┛┛┛━━━━━┛┛┛┛┛┛┛┛━┛┛┛┛┛┛ ┛ i i HHQ, 2001.02.07 homepage: www.suye.8u8.com ');
procedure TForm1.SendNextmail (var datteinc: integer); beginif ComboBox1.Items.Count> cursennum then begin inc (datteinc); statusbar1.Panels [0] .Text: = 'a total transmission (' inttostr (sendsuc sendfal) ') Times'; statusbar1.panels [1] .text: = 'Successful transmission (' INTSUC) ') seal'; statusbar1.panels [2] .Text: = 'Currently sent:' ComboBoX1. Items.Strings [cursennum] '@' edit4.Text; ComboBox1.text: = ComboBox1.items.strings [cursennum]; inc (cursennum); NMSMTP1.PostMessage.Attachments.AddStrings (listbox1.Items); NMSMTP1.PostMessage .Toaddress.add (ComboBox1.items.Strings [CURSENNUM] '@' edit4.text); NMSMTP1.SENDMAIL; END ELSE BEGIN Startsen: = false; button1.caption: = 'Start sending a letter'; showMessage ('Please Read the new sender process for letters to send. ' # 13 ' (Press the F1 key to get help information) '); edit1.enabled: = true; edit2.enabled: = true; edit3.enabled: = true; edit4.Enabled: = true; combobox1.Enabled: = true; button2.Enabled: = true; button1.Enabled: = false; edit4.SetFocus; end; end; procedure TForm1.Button3Click (Sender: TObject); beginif opendialog1.Execute Then Begin edit6.text: = opendialog1.FileName; NMSMTP1.PostMessage.Body.LoadFromFile (edit6.text); end; end; procedure TForm1.Button4Click (Sender: TObject); beginif opendialog1.Execute then begin ListBox1.Items.Add (opendialog1. Filename); end;
procedure TForm1.Button2Click (Sender: TObject); beginif opendialog1.Execute thenbeginbutton1.Caption: = 'start transmission'; button1.Enabled: = true; startsen: = false; sendsuc: = 0; sendfal: = 0; cursennum: = 0; ComboBox1.Text: = ComboBox1.Text: = ComboBox1.Text: = ComboBox1.items.strings [0]; Totaco: = ComboBox1.items.count; statusbar1.panels [3] .text: = 'total (' INTOSTR (TOTACO) ') Seal'; END ELSE BEGIN SHOWMESSAGE ('Due to the dictionary file, please fill it in the recipient bar.'); ComboBox1.Setfocus; end; end; procedure TFORM1. NMSMTP1SUCCESS (Sender: TOBJECT); Beginif Startsen Then SendNextmail (SendSuc);
Procedure tform1.nmsmtp1failure (sender: TOBJECT); Beginif Startsen Then SendNextmail (sendfal);
Procedure tform1.button1click (sender: TOBJECT); beginif edit4.text = '' TEN BEGIN SHOWMESAGE ('Please fill in the server column " # 13 ', for example: to send to XXX @ YYY .nnn fills in YYY.NNN '); ed =' .Setfocus; Else if ComboBox1.text = '' TEN BEGIN SHOWMESSAGE ('); Button2.Setfocus; button2.click; endelsebeginif Startsen Then Begin Startsen: = false; button1.caption: = 'Continue to send a letter'; edit1.enabled: = true; edit2.enabled: = true; edit3.enabled: = true; edit4.enabled: = true; comboBoX1.enabled: = True; button2.enabled: = true; end else begin edit1.enabled: = false; edit2.enabled: = false; edit3.enabled: = false; adt4.enabled: = false; comboBox1.enabled: = false; button2.enabled : = false; startsen: = true; nmsmtp1.host: = Edit1.Text; nmsmtp1.port: = start (edit3.text); nmsmtp1.userid: = Edit2.Text; button1.caption: = 'Suspension letter'; {if not connal dam nmsmtp1.connect; constribal: = true; showMessage ('yes'); end;} NMS MTP1.PostMessage.FromAddress: = Edit9.Text; NMSMTP1.PostMessage.FromName: = Edit8.Text; NMSMTP1.PostMessage.Subject: = Edit5.Text; SendNextmail (sendsuc); end; end; end; procedure TForm1.FormCloseQuery (Sender : TOBJECT; VAR CANCLOSE: Boolean; Begin NMSMTP1.Abort; End; Procedure TFORM1.NMSMTP1CONNECTIONFAILED (Sender: TOBJECT); Begin ShowMessage ('connection failed); connal: = false;
procedure TForm1.NMSMTP1ConnectionRequired (var Handled: Boolean); begin If MessageDlg ( 'You have not connection is connected', mtConfirmation, mbOkCancel, 0) = mrOk then Begin Handled: = TRUE; NMSMTP1.Connect; End; end;
Procedure tform1.nmsmtp1invalidhost (var handled: boolean); VARTMPSTR: STRING; Begin if INPUTQUERY ('Enter mail server address!', "Please enter the mail server address: ', tmpstr) THEN BEGIN NMSMTP1.HOST: = TmpStr; Edit1.Text : = TmpStr; Handled: = true;
END;
Procedure TFORM1.FormCreate (Sender: TOBJECT); begin connal: = false; startsen: = false;
procedure TForm1.Edit1Change (Sender: TObject); vartmpstr: string; begin tmpstr: = edit1.text; NMSMTP1.Host: = tmpstr; end; procedure TForm1.Edit2Change (Sender: TObject); begin NMSMTP1.UserID: = Edit2.Text ;
Procedure TFORM1.BUTTON5CLICK (Sender: TOBJECT); BeginListBox1.clear;
Procedure tform1.edit8keydown (Sender: Tobject; var key: word; shift: tshiftstate); beginif key = vk_return kiln; ed;
Procedure tform1.edit9keydown (Sender: Tobject; var key: word; shift: tshiftstate); beginif key = vk_return kiln; edit5.setfocus;
Procedure tform1.edit6keydown (Sender: Tobject; var key: word; shift: tshiftstate); beginif key = VK_RETURN THEN Edit1.Setfocus;
Procedure tform1.edit5keydown (Sender: Tobject; var key: word; shift: tshiftstate); beginif key = vk_return dam3.setfocus;
Procedure TFORM1.EDIT1KEYDOWN (Sender: Tobject; Var Key: Word; Shift: tshiftstate); beginif key = vk_return kiln.
END;
Procedure tform1.edit2keydown (Sender: Tobject; var key: word; shift: tshiftstate); beginif key = vk_return dam4.setfocus;
procedure TForm1.Edit4KeyDown (Sender: TObject; var Key: Word; Shift: TShiftState); beginif (key = vk_return) then if (combobox1.Items.Count = 0) then button2.SetFocus else button1.setfocus; end; procedure TForm1. ComboBox1KeyDown (Sender: TObject; var Key: Word; Shift: TShiftState); beginif (key = vk_return) and (comboBox1.Text <> '') thenbeginComboBox1.Items.Add (ComboBox1.text); ComboBox1.text: = '' Totaco: = ComboBox1.items.count; statusbar1.panels [3] .text: = '(' INTACO ') seal'; end; end;
Procedure tform1.formkeydown (Sender: Tobject; var key: word; shift: tshiftstate); beginif key = vk_f1 dam1.helpShow; end;
End.
Ok, after completing the above steps, then we just contact the individual components to each other, then we use Delphi's messages to complete. Of course, you can also modify it to make it more in line with your taste. Although there are more steps, at least we have made a letter.
Finally, tell you, do you want to be lazy, if, then, 嘿嘿 ..., then ..
Find a little dream to complete the program code, you can come fast, otherwise the little dream will run off a few days. The little dream of the little dream is: su_ye@163.net, home page www.suye.8u8.com