Fórum Mail #326609
01/08/2006
0
Estou usando a seguinte rotina para enviar e-mail de um banco de dados
´Nomes´
procedure TFormNomes.enviarClick(Sender: TObject);
var xAnexo : Integer;
// verifica se tem conexão
Flags: dword;
X: dword;
S, temconexao: string;
begin
IdMessage.From.Name := edtnome.Text;
IdMessage.From.Address := edtendereco.Text;
IdMessage.From.Text := ´´´+edtnome.Text+´´´+´<´+edtendereco.Text+´>´;
IdSMTP.Host := edtservidor.Text;
IdSMTP.Username := edtconta.Text;
IdSMTP.Password := edtsenha.Text;
edtPara.Text := DNOMES.C_T_MAIL.Text;
IdMessage.Recipients.EMailAddresses := edtPara.Text;
case cbxPrioridade.ItemIndex of
0 : IdMessage.Priority := mpHigh;
1 : IdMessage.Priority := mpNormal;
2 : IdMessage.Priority := mpLow;
end;
IdMessage.Subject := edtAssunto.Text;
IdMessage.Body := mmMensagem.Lines;
if cbxConfirmaLeitura.Checked then
IdMessage.ReceiptRecipient.Text := IdMessage.From.Text; // Auto Resposta
idSMTP.Connect;
try
enviosim := IdSMTP.Send(IdMessage);
DNOMES.Edit;
DNOMES.DATA_ENVIO.Conteudo := date;
DNOMES.Post;
DNOMES.Next;
finally
IdSMTP.Disconnect;
end;
end;
O problema é o seguinte. Se o DNOMES.C_T_MAIL.Text não for um e-mail válido (não exista), o programa dar um erro e para o loop ;
Tem como saber se o e-mail é valido, algo como e lá no servidor e verificar ?
´Nomes´
procedure TFormNomes.enviarClick(Sender: TObject);
var xAnexo : Integer;
// verifica se tem conexão
Flags: dword;
X: dword;
S, temconexao: string;
begin
IdMessage.From.Name := edtnome.Text;
IdMessage.From.Address := edtendereco.Text;
IdMessage.From.Text := ´´´+edtnome.Text+´´´+´<´+edtendereco.Text+´>´;
IdSMTP.Host := edtservidor.Text;
IdSMTP.Username := edtconta.Text;
IdSMTP.Password := edtsenha.Text;
edtPara.Text := DNOMES.C_T_MAIL.Text;
IdMessage.Recipients.EMailAddresses := edtPara.Text;
case cbxPrioridade.ItemIndex of
0 : IdMessage.Priority := mpHigh;
1 : IdMessage.Priority := mpNormal;
2 : IdMessage.Priority := mpLow;
end;
IdMessage.Subject := edtAssunto.Text;
IdMessage.Body := mmMensagem.Lines;
if cbxConfirmaLeitura.Checked then
IdMessage.ReceiptRecipient.Text := IdMessage.From.Text; // Auto Resposta
idSMTP.Connect;
try
enviosim := IdSMTP.Send(IdMessage);
DNOMES.Edit;
DNOMES.DATA_ENVIO.Conteudo := date;
DNOMES.Post;
DNOMES.Next;
finally
IdSMTP.Disconnect;
end;
end;
O problema é o seguinte. Se o DNOMES.C_T_MAIL.Text não for um e-mail válido (não exista), o programa dar um erro e para o loop ;
Tem como saber se o e-mail é valido, algo como e lá no servidor e verificar ?
Zlink
Curtir tópico
+ 0
Responder
Posts
01/08/2006
Motta
Coloque num bloco Try Except End , trate o erro e siga o enterro ...
Responder
Gostei + 0
01/08/2006
Zlink
Coloquei o checkbox no form e:
if Ch_Autentica.checked = true then
idSMTP.AuthenticationType := atLogin
else
idSMTP.AuthenticationType := atNone;
Desta forma mesmo com o e-mail errado, ele será enviado, vai dar retorno na caixa postal.
if Ch_Autentica.checked = true then
idSMTP.AuthenticationType := atLogin
else
idSMTP.AuthenticationType := atNone;
Desta forma mesmo com o e-mail errado, ele será enviado, vai dar retorno na caixa postal.
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)