nect.Enabled:=False;
ButtonDisConnect.Enabled:=True;
end;
procedure TFSMTP.ButtonDisconnectClick(Sender: TObject);
begin
NMSMTP1.Disconnect;
ButtonConnect.Enabled:=True;
ButtonDisConnect.Enabled:=False;
end;
procedure TFSMTP.NMSMTP1Connect(Sender: TObject);
begin
StatusBar1.SimpleText:=''已经连接'';
Panel1.Color:=clBlue;
end;
procedure TFSMTP.NMSMTP1Disconnect(Sender: TObject);
begin
if StatusBar1<>nil then begin
StatusBar1.SimpleText:=''断开连接'';
Panel1.Color:=clRed;
end;
end;
procedure TFSMTP.ButtonAddClick(Sender: TObject);
begin
if OpenDialog1.Execute then
ListBoxAttachments.Items.Add(OpenDialog1.FileName);
end;
procedure TFSMTP.ButtonRemoveClick(Sender: TObject);
begin
ListBoxAttachments.Items.Delete(ListBoxAttachments.ItemIndex);
end;
procedure TFSMTP.ButtonSendClick(Sender: TObject);
{var
i_sum,i_count:integer;
s_To:string;
begin
i_sum:=0;i_count:=0;
with DBGrid1.DataSource.DataSet do
if (isempty=false) and (recordcount>0) then begin
Application.CreateForm(TFormSending, FormSending);
FormSending.Show;
FormSending.Label1.Caption:=''共''+inttostr(recordcount)+''封邮件'';
FormSending.Label4.Caption:=FormSending.Label1.Caption;
DisableControls;
first;
while not eof do begin
s_To:=Query1.FindField(''电子邮箱'').asstring;
i_sum:=i_sum+1;
if (trim(s_to)='''')and(pos(''@'',s_To)<=0) then begin
i_count:=i_count+1;
FormSending.Label3.Caption:=''目前共有''+inttostr(i_count)+''封空白的邮件地址'';
FormSending.Label6.Caption:=FormSending.Label3.Caption;
end
else begin
FormSending.Label2.Caption:=''正在发送第''+inttostr(i_sum)+''封邮件 '';
FormSending.Label5.Caption:=FormSending.Label2.Caption;
Editto.Text:=s_to;
// EditBCC.Text:=s_to;
// EditCC.Text:=s_to;
NMSMTP1.PostMessage.FromAddress:=EditAddress.Text;
NMSMTP1.PostMessage.FromName:=EditName.Text;
NMSMTP1.PostMessage.Subject:=EditSubject.Text;
NMSMTP1.PostMessage.ToAddress.Text:=Editto.Text;
// NMSMTP1.PostMessage.ToBlindCarbonCopy.Add(EditBCC.Text);
// NMSMTP1.PostMessage.ToCarbonCopy.Add(EditCC.Text);
NMSMTP1.PostMessage.Attachments.AddStrings(ListBoxAttachments.Items);
NMSMTP1.PostMessage.Body.Assign(MemoMail.Lines);
NMSMTP1.SendMail; //
// ts_CC.Add(s_To);
end;
next;
end;
EnableControls;
end;
ShowMessage(''邮件发送完毕!#1'');
FormSending.Close;//}
//---------------------------------------------------
var
s_To:string;
// ts_To: TStrings;
begin
// ts_To:=TStringList.Create;
// ts_To.Clear;
with DBGrid1.DataSource.DataSet do begin
first;
DBGrid1.DataSource.DataSet.DisableControls;
while not eof do begin
s_To:=Query1.FindField(''电子邮箱'').asstring;
if (trim(s_To)<>'''')and(pos(''@'',s_To)>0) then begin
//ts_To.Add(s_To);
Memo1.Lines.Add(s_To);