我这个就是刚下的,但是还是不行
第一个记录老是没有附件,第二个记录的附件是第一个的,依次类推。
请Hiyaolee看一下,谢谢先了
代码如下:
Tb_Send.Enabled := False;
Screen.Cursor := crHourGlass;
Aq_Send.First;
for I := 0 to Aq_Send.RecordCount - 1 do begin
if aq_SendSend_Yn.Value = True then begin
E_Mail := Aq_SendE_Mail.AsString;
Edit1.Text := Aq_SendAccessories.AsString;
AccFileName := Aq_SendAccessories.AsString;
try
Main_Bar.Panels[1].Text := '请稍等......';
Smtp_Send.Host := MailServer;
Sm_Send.CharSet := 'iso-8859-1';
Sm_Send.TextEncoding := teQP;
Sm_Send.UserName := PName;
Sm_Send.From := MailName;
Sm_Send.SendTo := E_Mail;
Sm_Send.Subject := E_Topic.Text;
Sm_Send.Text.Assign(M_Matter.Lines);
if Smtp_Send.Connect then begin
Main_Bar.Panels[1].Text := ' 已经联接!';
Smtp_Send.UserId := EUser;
Smtp_Send.UserPasswd := EPassword;
if not Smtp_Send.Login then begin
Main_Bar.Panels[1].Text := ' 用户登录失败!联接关闭';
Smtp_Send.Disconnect;
Exit;
end
else
Main_Bar.Panels[1].Text := ' 用户登录成功!';
end;
if not Smtp_Send.SMTPError then begin
Sm_Send.LocalHost := Smtp_Send.LocalHost;
Sm_Send.LocalAddr := Smtp_Send.LocalAddr;
Tb_Calcel.Enabled := True;
Smtp_Send.SendTheMessage(Sm_Send);
Tb_Calcel.Enabled := False;
if not Smtp_Send.SMTPError then
Smtp_Send.Disconnect;
end;
finally
if Length(Trim(AccFileName)) > 0 then begin
Sm_Send.Free;
Sm_Send := TSakMsg.Create(Self);
Sm_Send.AttachedFiles.Clear;
Sm_Send.AttachedFiles.add(AccFileName);
Screen.Cursor := crDefault;
Tb_Send.Enabled := True;
Progress.Position := 0;
end
else begin
Sm_Send.Free;
Sm_Send := TSakMsg.Create(self);
Screen.Cursor := crDefault;
Tb_Send.Enabled := True;
Progress.Position := 0;
end;
end;
Aq_Send.Next;
end
else
Aq_Send.Next;
Screen.Cursor := crDefault;
Tb_Send.Enabled := True;
Progress.Position := 0;
end;