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.

171 lines
4.6 KiB
Plaintext

unit U_SendMail;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,DB,inifiles, Buttons,ShellAPI, IdMessage,
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdExplicitTLSClientServerBase, IdMessageClient, IdSMTPBase, IdSMTP,IdAttachmentFile,
IdIOHandler, IdIOHandlerSocket, IdIOHandlerStack, IdSSL, IdSSLOpenSSL;
type
TfrmSendMail = class(TForm)
Label2: TLabel;
Edit1: TEdit;
SpeedButton9: TSpeedButton;
SpeedButton3: TSpeedButton;
OpenDialog1: TOpenDialog;
Label4: TLabel;
Edit3: TEdit;
Label5: TLabel;
ComboBox1: TComboBox;
Label1: TLabel;
Memo1: TMemo;
SMTP1: TIdSMTP;
IdMsg: TIdMessage;
IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL;
procedure FormShow(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton9Click(Sender: TObject);
procedure ComboBox1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
private
{ Private declarations }
public
mblno,EMAILRECVER,EMAILRECVER2:string;
{ Public declarations }
end;
var
frmSendMail: TfrmSendMail;
implementation
uses my_sys_function,u_sys_frprint;
{$R *.dfm}
procedure TfrmSendMail.FormShow(Sender: TObject);
var
inifile1:Tinifile;
begin
mblno:=frm_sys_frprint.frxReport1.FileName;
// Edit2.Text:=frmPrint.frxReport1.FileName;
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
EMAILRECVER:=inifile1.ReadString('EDIDATA','EMAILRECVER','cangdan@eportyun.com');
EMAILRECVER2:=inifile1.ReadString('EDIDATA','EMAILRECVER2','myshipping@myshipping.net');
ComboBox1.Items.Clear;
ComboBox1.Items.Add('QDDS/땜價/'+mblno+'/覩迦꾐데');
ComboBox1.Items.Add('QDDS/땜價/'+mblno+'/錦맣꾐데');
ComboBox1.Items.Add('QDDS/땜價/'+mblno+'/<2F>뇜꾐데');
ComboBox1.ItemIndex:=0;
end;
procedure TfrmSendMail.SpeedButton3Click(Sender: TObject);
begin
close;
end;
procedure TfrmSendMail.SpeedButton9Click(Sender: TObject);
Var
mail: TStringList;
ScriptPath,str,fileext:string;
template : TStream;
inifile1:TIniFile;
begin
fileext:='.xls';
ScriptPath:=ExtractFilePath(ParamStr(0))+'CUSTOMFILE\';
ScriptPath:=Copy(ScriptPath,0,3)+'temp\';
if not DirectoryExists(ScriptPath) then
CreateDir(ScriptPath);
str:=ScriptPath
+mblno+fileext;
if frm_sys_frprint.t_sys_report.isempty then
exit;
frm_sys_frprint.t_sys_reportfile.Close;
frm_sys_frprint.t_sys_reportfile.SQL.Clear;
frm_sys_frprint.t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(frm_sys_frprint.t_sys_report['CH_ID']));
frm_sys_frprint.t_sys_reportfile.Open;
try
try
template := frm_sys_frprint.t_sys_reportfile.CreateBlobStream(frm_sys_frprint.t_sys_reportfile.FieldByName('report'), bmRead);
template.Position := 0;
frm_sys_frprint.frxReport1.LoadFromStream(template);
finally
template.Free;
end;
frm_sys_frprint.frxReport1.PrepareReport;
frm_sys_frprint.frxXLSExport1.ShowDialog:=false;
frm_sys_frprint.frxXLSExport1.FileName:=str;
frm_sys_frprint.frxReport1.Export(frm_sys_frprint.frxXLSExport1);
SMTP1.AuthType := satDefault;
SMTP1.username:=get_parameters_value(179,'');
SMTP1.Password :=get_parameters_value(180,'');
SMTP1.Host:=get_parameters_value(181,'');
SMTP1.Port:=25;
try
SMTP1.Connect;
except
on e : Exception do
begin
ShowMessage('젯쌈錟芎놔댄:'+E.Message);
end;
end;
if not SMTP1.Connected then
begin
Sleep(1000);
SMTP1.Connect;
end;
try
with IdMsg do
begin
body.Clear;
Body.Text :=Memo1.lines.Text;
From.address :=get_parameters_value(179,'');
Recipients.EMailAddresses :=Edit1.text;
CCList.EMailAddresses := Edit3.Text;
Subject:=ComboBox1.text;
TIdAttachmentFile.Create(MessageParts,str);
end;
if not SMTP1.Connected then
begin
Sleep(1000);
SMTP1.Connect;
end;
SMTP1.Send(IdMsg);
finally
SMTP1.Disconnect;
end;
MessageDlg('랙箇냥묘!',mtConfirmation,[mbOK],0);
except
MessageDlg('랙箇呵겨!',mtError,[mbOK],0);
end;
if SMTP1.Connected then SMTP1.Disconnect;
end;
procedure TfrmSendMail.ComboBox1DragOver(Sender, Source: TObject; X,
Y: Integer; State: TDragState; var Accept: Boolean);
begin
ComboBox1.Text:=StringReplace(ComboBox1.Text,'瓊데뵀',mblno,[]);
end;
end.