Enviar email para UOL com conexão Segura com INDY
Boa Tarde pessoal estou tentando enviar um email usando o smtps.uol.com.br mas não estou tendo sucesso , todos que não precisam de autenticação fucionam mas esse não vai o codigo que estou usando segue abaixo:
procedure TF_Enviaremail.envia;
Var vconexao_segura:boolean;
varquivoXML,vArquivoPDF:string;
vAno,vMes,vDia : Word;
label inicio;
begin
DecodeDate(F_CadNFe.TBNota.FieldByName('emissao').AsDateTime,vAno,vMes,vDia);
inicio:
StatusBar1.Panels[0].Text:='Aguarde !!! Enviando e-mail...';
Application.ProcessMessages;
// Adiciona o HTML ao corpo da mensagem
IdMessage.Body.Clear;
IdMessage.Body.Add('Prezados Senhores,segue em anexo o xml da NFe,de acordo com o manual do contribuinte 4.0.1 ');
varquivoXML := ExtractFilePath(Application.ExeName)+'NFe\NFe_Transmitidas\'+StrZero(vAno,4)+StrZero(vMes,2)+'\NFe\'+F_CadNFe.TBNota.FieldByName('chv_nfe').AsString+'-nfe.xml';
vArquivoPDF := ExtractFilePath(Application.ExeName)+'NFe\NFe_PDF\'+F_CadNFe.TBNota.FieldByName('chv_nfe').AsString+'.pdf';
TIdAttachment.create(IdMessage.MessageParts,varquivoXML );
TIdAttachment.create(IdMessage.MessageParts,vArquivoPDF );
IdSMTP.Username := F_CadNFe.IBQEmpresa.fieldByName('email').AsString;
IdSMTP.Password := F_CadNFe.IBQEmpresa.fieldByName('senha').AsString;
IdSMTP.Host := F_CadNFe.IBQEmpresa.fieldByName('smtp').AsString;
IdSMTP.Port := F_CadNFe.IBQEmpresa.fieldByName('porta_email').AsInteger;
IdMessage.Subject := 'Arquivo xml NFe ';
IdMessage.From.Address := F_CadNFe.IBQEmpresa.fieldByName('email').AsString;
IdMessage.From.Name := F_CadNFe.IBQEmpresa.fieldByName('fant').AsString;
IdMessage.Recipients.EMailAddresses := email.Text;
if F_CadNFe.IBQEmpresa.fieldByName('email_conexao_segura').AsString = 'S' then
begin
IdSMTP.IOHandler := AuthSSL;
end ;
Try
IdSMTP.Disconnect;
IdSMTP.ReadTimeOut := 20000;
IdSMTP.AuthenticationType := atLogin;
IdSMTP.Connect;
if IdSMTP.Connected then Begin
IdSMTP.Authenticate;
IdSMTP.Send(IdMessage);
erro:=0;
End;
except
erro:=1;
end;
IdSMTP.Disconnect;
if (erro=0) and (Application.MessageBox('Mensagem Enviada com Sucesso, deseja reenviar e-mail ?','Confirmação', MB_ICONQUESTION+MB_YESNO+MB_DEFBUTTON2)=mryes) then begin
goto inicio;
end
else if (erro = 0) then
StatusBar1.Panels[0].Text := 'Email enviado com sucesso !...';
if (erro=1) and (Application.MessageBox('Erro no envio do e-mail, deseja tentar enviar e-mail novamente ?','Confirmação', MB_ICONQUESTION+MB_YESNO+MB_DEFBUTTON2)=mryes) then begin
goto inicio;
end
else if (erro=1) then
StatusBar1.Panels[0].Text := 'Erro ao tentar enviar email !...';
end;
O erro erro que retona é: 'Error connecting with SSL';
Já coloquei as DLLs(libeay32.dll,ssleay32.dll) na System32 e não vai , será que alguem pode me ajudar ,desde já agradeço a atenção...
procedure TF_Enviaremail.envia;
Var vconexao_segura:boolean;
varquivoXML,vArquivoPDF:string;
vAno,vMes,vDia : Word;
label inicio;
begin
DecodeDate(F_CadNFe.TBNota.FieldByName('emissao').AsDateTime,vAno,vMes,vDia);
inicio:
StatusBar1.Panels[0].Text:='Aguarde !!! Enviando e-mail...';
Application.ProcessMessages;
// Adiciona o HTML ao corpo da mensagem
IdMessage.Body.Clear;
IdMessage.Body.Add('Prezados Senhores,segue em anexo o xml da NFe,de acordo com o manual do contribuinte 4.0.1 ');
varquivoXML := ExtractFilePath(Application.ExeName)+'NFe\NFe_Transmitidas\'+StrZero(vAno,4)+StrZero(vMes,2)+'\NFe\'+F_CadNFe.TBNota.FieldByName('chv_nfe').AsString+'-nfe.xml';
vArquivoPDF := ExtractFilePath(Application.ExeName)+'NFe\NFe_PDF\'+F_CadNFe.TBNota.FieldByName('chv_nfe').AsString+'.pdf';
TIdAttachment.create(IdMessage.MessageParts,varquivoXML );
TIdAttachment.create(IdMessage.MessageParts,vArquivoPDF );
IdSMTP.Username := F_CadNFe.IBQEmpresa.fieldByName('email').AsString;
IdSMTP.Password := F_CadNFe.IBQEmpresa.fieldByName('senha').AsString;
IdSMTP.Host := F_CadNFe.IBQEmpresa.fieldByName('smtp').AsString;
IdSMTP.Port := F_CadNFe.IBQEmpresa.fieldByName('porta_email').AsInteger;
IdMessage.Subject := 'Arquivo xml NFe ';
IdMessage.From.Address := F_CadNFe.IBQEmpresa.fieldByName('email').AsString;
IdMessage.From.Name := F_CadNFe.IBQEmpresa.fieldByName('fant').AsString;
IdMessage.Recipients.EMailAddresses := email.Text;
if F_CadNFe.IBQEmpresa.fieldByName('email_conexao_segura').AsString = 'S' then
begin
IdSMTP.IOHandler := AuthSSL;
end ;
Try
IdSMTP.Disconnect;
IdSMTP.ReadTimeOut := 20000;
IdSMTP.AuthenticationType := atLogin;
IdSMTP.Connect;
if IdSMTP.Connected then Begin
IdSMTP.Authenticate;
IdSMTP.Send(IdMessage);
erro:=0;
End;
except
erro:=1;
end;
IdSMTP.Disconnect;
if (erro=0) and (Application.MessageBox('Mensagem Enviada com Sucesso, deseja reenviar e-mail ?','Confirmação', MB_ICONQUESTION+MB_YESNO+MB_DEFBUTTON2)=mryes) then begin
goto inicio;
end
else if (erro = 0) then
StatusBar1.Panels[0].Text := 'Email enviado com sucesso !...';
if (erro=1) and (Application.MessageBox('Erro no envio do e-mail, deseja tentar enviar e-mail novamente ?','Confirmação', MB_ICONQUESTION+MB_YESNO+MB_DEFBUTTON2)=mryes) then begin
goto inicio;
end
else if (erro=1) then
StatusBar1.Panels[0].Text := 'Erro ao tentar enviar email !...';
end;
O erro erro que retona é: 'Error connecting with SSL';
Já coloquei as DLLs(libeay32.dll,ssleay32.dll) na System32 e não vai , será que alguem pode me ajudar ,desde já agradeço a atenção...
Jorge
Curtidas 0
Respostas
José
17/02/2011
Este tópico esta sendo fechado por inatividade. Se necessário, sinalizar para que seja reaberto ou abrir um novo.
GOSTEI 0