uses Classes, Graphics, Controls, Forms,System, Dialogs, UnMain,undm,IbQuery,DB,ShellApi,SysUtils; var stroka,header,export_str,path, filename, footer,SQL,sname,ware_id,org_name,date_export,izg_name,country,quant,price:String; q: TIBQuery; sl :TStringList; procedure send_messgage_email var s,t:String; adr_smtp,adr_port,adr_psw,adr_otprav,client,f, organization,ssl,adr_poluch,subj,body: String; i: Integer; begin subj:='ExportTO1C'; body:='Выгрузка из аптеки'+StringReplace(org_name,'"','',1); frmManagerXP2.logit(body); q.Active:=false; q.SQL.text:='select PARAM_VALUE from PARAMS where PARAM_ID=''PARAMS_SMTP'''; q.Active:=true; adr_smtp:=q.FieldByname('PARAM_VALUE').AsString; q.Active:=false; q.SQL.text:='select PARAM_VALUE from PARAMS where PARAM_ID=''PARAMS_PORT'''; q.Active:=true; adr_port:=q.FieldByname('PARAM_VALUE').AsString; q.Active:=false; q.SQL.text:='select PARAM_VALUE from PARAMS where PARAM_ID=''PARAMS_PSW'''; q.Active:=true; adr_psw:=q.FieldByname('PARAM_VALUE').AsString; q.Active:=false; q.SQL.text:='select PARAM_VALUE from PARAMS where PARAM_ID=''EMAIL'''; q.Active:=true; adr_otprav:=q.FieldByname('PARAM_VALUE').AsString; q.Active:=false; q.SQL.text:='select PARAM_VALUE from PARAMS where PARAM_ID=''ORG_NAME_SHORT'''; q.Active:=true; organization:=q.FieldByname('PARAM_VALUE').AsString; q.Active:=false; q.SQL.text:='select PARAM_VALUE from PARAMS where PARAM_ID=''PARAMS_AUTOTLS'''; q.Active:=true; ssl := ''; if (q.FieldByname('PARAM_VALUE').AsString='Да') then ssl := ssl + 'AUTOTLS'; q.Active:=false; q.SQL.text:='select PARAM_VALUE from PARAMS where PARAM_ID=''PARAMS_FULLSSL'''; q.Active:=true; if (q.FieldByname('PARAM_VALUE').AsString='Да') then ssl := ssl + ' FULLSSL'; q.Active:=false; f:='file0="'+path+filename+'"'; adr_poluch:='d_dmitry@standart-n.ru'; if trim(adr_poluch)<>'' then begin t:=ssl+' host='+adr_smtp+' port='+adr_port+' User='+adr_otprav+' Pass='+adr_psw+' FROMEMAIL='+adr_otprav+ ' TOEMAIL='+adr_poluch+' SUBJ="'+subj+'" BODY="'+body+'" '+f; frmManagerXP2.logit(t); try i:=ShellExecute(0, 'open','c:\Standart-N\VGMCSend\VGMCSend.exe', t, '', 5); //copyfile(katalog+ExtractFileName(edit1.text),katalog+ExtractFileName(edit1.text),1); sleep(1000); except frmManagerXP2.logit('Некорректно: email: '+adr_poluch); end end; end; begin sl:=TStringList.Create; path:='e:\Standart-N\'; filename:='export.xml'; date_export:=DateToStr(now); //org_name:='Халык'; SQL:='select p.param_value as org_name from params p where p.param_id=''ORG_NAME_SHORT'''; q := dm.TempQuery(nil); q.Sql.text:=SQL; q.active:= true; org_name:=q.FieldByName('org_name').Asstring; q.active:= false; header:=' <Главный ВерсияФормата="2"> <Аптека Организация="%org_name%" ТипЦены="Розничная" ДатаВыгрузки="%date_export%">'; header:=StringReplace(header,'%date_export%',date_export,1); header:=StringReplace(header,'%org_name%',org_name,1); stroka:=' <ТОВАР> <Наименование>%sname% <УникальныйИдентификатор>%ware_id% <ДетальныеДанные> <Наименование>%sname% <НаименованиеПолное>%sname% %izg_name% %country% <Артикул/> <КодНоменклатуры> <ТипЦен>Розничная <ЕдиницаЦены>шт <БазоваяЕдиницаИзмерения>шт <ЕдиницаХраненияОстатков>шт <СтранаПроисхождения/> <КоличествоОстатокВЕдиницеОстатка>%quant% <Цена>%price% '; footer:=' '; SQL:='select w.sname, w.ware_id, coalesce(w.sizg, '''') as izg_name, coalesce(w.scountry, '''') as country, w.quant, w.price from vw_warebase w where w.quant>0' q := dm.TempQuery(nil); // try q.Sql.text:=SQL; q.active:= true; // BROWSER_PATH :=q2.FieldByName('param_value').Asstring; // finally // q.free; sl.Add(UTF8Encode(header)); // end; while not q.eof do begin sname:=StringReplace(q.FieldByName('sname').Asstring,'&','&',1); ware_id:=q.FieldByName('ware_id').Asstring; quant:=q.FieldByName('quant').Asstring; price:=q.FieldByName('price').Asstring; izg_name:=StringReplace(q.FieldByName('izg_name').Asstring,'&','&',1); country:=q.FieldByName('country').Asstring; export_str:=StringReplace(stroka,'%sname%',sname,1); export_str:=StringReplace(export_str,'%ware_id%',ware_id,1); export_str:=StringReplace(export_str,'%quant%',quant,1); export_str:=StringReplace(export_str,'%price%',price,1); export_str:=StringReplace(export_str,'%izg_name%',izg_name,1); export_str:=StringReplace(export_str,'%country%',country,1); export_str:=UTF8Encode(export_str); sl.Add(export_str); q.Next end sl.Add(UTF8Encode(footer)); sl.SaveToFile(path+filename); sl.Clear; send_messgage_email; Showmessage('Файл выгружен - '+path+filename); end;