You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
4.7 KiB
Plaintext

11 months ago
unit u_crm_client_check_do;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, BusinessSkinForm, bsSkinCtrls, StdCtrls, Mask, DBCtrls, DB,
ADODB, Psock, NMsmtp, IdComponent, IdTCPConnection, IdTCPClient,
IdMessageClient, IdSMTP, IdBaseComponent, IdMessage,
IdExplicitTLSClientServerBase, IdSMTPBase;
type
Tfrm_crm_client_check_do = class(TForm)
bsBusinessSkinForm1: TbsBusinessSkinForm;
bsSkinButton3: TbsSkinButton;
bsSkinButton2: TbsSkinButton;
Label4: TLabel;
DBEdit4: TDBEdit;
DBEdit5: TDBEdit;
Label5: TLabel;
IdMsg: TIdMessage;
SMTP1: TIdSMTP;
procedure bsSkinButton2Click(Sender: TObject);
procedure bsSkinButton3Click(Sender: TObject);
procedure NMSMTP1Connect(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frm_crm_client_check_do: Tfrm_crm_client_check_do;
implementation
uses u_crm_client_check, u_data_share, my_sys_function;
{$R *.dfm}
procedure Tfrm_crm_client_check_do.bsSkinButton2Click(Sender: TObject);
begin
close;
end;
procedure Tfrm_crm_client_check_do.bsSkinButton3Click(Sender: TObject);
var
aQuery:TAdoQuery;
str,emp,mail:String;
begin
try
frm_crm_client_check.t_crm_client.edit;
frm_crm_client_check.t_crm_client['<27>ͻ<EFBFBD>״̬']:='<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>';
frm_crm_client_check.t_crm_client.post;
except
showmessage('<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>');
exit;
end;
aQuery:=CreateAdoQuery;
try
aQuery.Close;
aQuery.SQL.Clear;
aQuery.SQL.Add('Select * from t_crm_client_sales where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''Լ<><D4BC>ʱ<EFBFBD><CAB1>'' and <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+frm_crm_client_check.t_crm_client['<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>']+'''');
aQuery.Open;
if not aQuery.IsEmpty then begin
aQuery.Close;
aQuery.SQL.Clear;
aQuery.SQL.Add('Select * from t_sys_awoke where <20><><EFBFBD><EFBFBD>״̬=''׼<><D7BC>ִ<EFBFBD><D6B4>'' AND <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''<27>¿ͻ<C2BF><CDBB><EFBFBD><EFBFBD><EFBFBD>'' AND <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><='''+FormatDateTime('YYYY-MM-DD',NOW)+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='''+FormatDateTime('YYYY-MM-DD',NOW)+'''');
aQuery.Open;
if not aQuery.IsEmpty then begin
str:=Trim(aQuery.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString);
emp:=Copy(str,pos('<27><><EFBFBD><EFBFBD>=',str)+5,length(str)-pos('<27><><EFBFBD><EFBFBD>=',str)-3);
mail:=GetEmail(emp);
if mail<>'' then begin
SMTP1.AuthType := satDefault; //(satNone, satDefault, satSASL);
// SMTP1.AuthenticationType := atLogin;
SMTP1.username:= frm_data_share.t_sys_company.FieldByName('<27><>¼<EFBFBD>û<EFBFBD><C3BB><EFBFBD>').AsString;
SMTP1.Password :=frm_data_share.t_sys_company.FieldByName('<27><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>').AsString;
SMTP1.Host :=frm_data_share.t_sys_company.FieldByName('SMTP<54><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ').AsString;
SMTP1.Port :=Strtointdef(Trim(frm_data_share.t_sys_company.FieldByName('SMTP<54><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>').AsString),25);
try
SMTP1.Connect;
except
Showmessage('<27><><EFBFBD><EFBFBD>SMTP<54><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!');
Exit;
end;
try
with IdMsg do
begin
body.Clear;
Body.Text :='<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>:'+frm_crm_client_check.t_crm_client['<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>']+'<27><><EFBFBD><EFBFBD><EBB8B4>';
From.address :=frm_data_share.t_sys_company.FieldByName('SMTP<54><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
Recipients.EMailAddresses :=mail;
Subject:='<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>:'+frm_crm_client_check.t_crm_client['<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>']+'<27><><EFBFBD><EFBFBD><EBB8B4>';
end;
SMTP1.Send(IdMsg);
finally
// showmessage(t_sys_awoke_emp.FieldByName('<27><>Ա').asstring+'<27><><EFBFBD>ż<EFBFBD><C5BC>ѳɹ<D1B3><C9B9><EFBFBD><EFBFBD><EFBFBD>');
SMTP1.Disconnect;
end;
{
NMSMTP1.Host:=frm_data_share.t_sys_company.FieldByName('SMTP<54><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ').AsString;
NMSMTP1.Port:=Strtointdef(Trim(frm_data_share.t_sys_company.FieldByName('SMTP<54><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>').AsString),25);
if NMSMTP1.Connected then
begin
NMSMTP1.Disconnect;
end;
NMSMTP1.Connect;
NMSMTP1.PostMessage.FromAddress :=frm_data_share.t_sys_company.FieldByName('SMTP<54><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
NMSMTP1.PostMessage.FromName :='<27>ʼ<EFBFBD><CABC>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>';
NMSMTP1.PostMessage.ToAddress.Text :=mail;
NMSMTP1.PostMessage.Body.Text :='<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>:'+frm_crm_client_check.t_crm_client['<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>']+'<27><><EFBFBD><EFBFBD><EBB8B4>';
NMSMTP1.PostMessage.Subject :='<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>:'+frm_crm_client_check.t_crm_client['<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>']+'<27><><EFBFBD><EFBFBD><EBB8B4>';
NMSMTP1.SendMail;
}
end;
end;
end;
finally
FreeAndNil(aQuery);
end;
showmessage('<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>');
close;
end;
procedure Tfrm_crm_client_check_do.NMSMTP1Connect(Sender: TObject);
var
StrUserName,strPassword:String;
begin
{
strUserName:=EncodeString(frm_data_share.t_sys_company.FieldByName('<27><>¼<EFBFBD>û<EFBFBD><C3BB><EFBFBD>').AsString);
strPassword:=EncodeString(frm_data_share.t_sys_company.FieldByName('<27><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>').AsString);
nmsmtp1.Transaction('EHLO') ;
nmsmtp1.Transaction('AUTH LOGIN');
nmsmtp1.Transaction(strUserName);
nmsmtp1.Transaction(strPassword);
}
end;
end.