PAGUE 6 MESES
LEVE 12 MESES
GARANTIR DESCONTO

Fórum falta pouco pra mandar email #380804

06/07/2010

0

Envio de email, já rodei toda internet e nao consigo fazer rodar este codigo, uso o delphi 7   já baixei as dll http://indy.fulgan.com/SSL/indy_OpenSSL096m.zip   Componentes   TEdit;
  Name := 'edtRemet'; TEdit;
  Name := 'edtDest'; TEdit;
  Name := 'edtAssunto'; TListBox;
  Name := 'lbAnexos';
  Ctl3D := False; TBitBtn;
  Name := 'btAnexar';
  Caption := 'Anexar arquivo';
TMemo;
  Name := 'memoMSG';
  ScrollBars := ssBoth;   TBitBtn;
TBitBtn;
  Name := 'btEnviar';
  Caption := 'Enviar'; TStatusBar;
  Name := 'statusBar';  (Não esqueça de adicionar um panel)
TOpenDialog;
  Name := 'OpenDialog1';
  Options := [ofHideReadOnly, ofAllowMultiSelect, ofEnableSizing]; TIdSMTP;
  Name := 'SMTP';
  IOHandler := SSLSocket; <- Aki você linka com o componente TIdSSLIOHandlerSocket.
  Host := 'smtp.gmail.com';
  Port := 465;
  AuthenticationType := atLogin;
  Password := 'senha';
  Username := 'seu_gmail@gmail.com'; TIdSSLIOHandlerSocket;
  Name := 'SSLSocket';
  SSLOptions.Method := sslvSSLv2;
  SSLOptions.Mode := sslmUnassigned;
  SSLOptions.VerifyMode := [];
  SSLOptions.VerifyDepth := 0;
  OnStatusInfo := SSLSocketStatusInfo; TIdMessage;
  Name := 'Mesage';   Formulário  
  Código   Evento StatusInfo do Componente SSLSocket (TIdSSLIOHandlerSocket) procedure TForm1.SSLSocketStatusInfo(Msg: String);
begin
  Application.ProcessMessages;
  statusBar.Panels[0].Text := 'idSSL: ' + Msg;
end; Evento Status do Componente SMTP (TIdSMTP)  procedure TForm1.SMTPStatus(ASender: TObject; const AStatus: TIdStatus;
  const AStatusText: String);
begin
  Application.ProcessMessages;
  statusBar.Panels[0].Text := 'idSMTP: ' + AStatusText;
end;  Evento Click do Componente btAnexar (Botao anexar) procedure TForm1.btAnexarClick(Sender: TObject);
var
  i: integer;
begin
  if OpenDialog1.Execute then
  begin
    for i:= 0 to OpenDialog1.Files.Count -1 do
    if (lbAnexos.Items.IndexOf(OpenDialog1.Files[i]) = -1) then
      lbAnexos.Items.Add(OpenDialog1.Files[i])
  end;
end; Evento Click do Componente btEnviar (Botão Enviar)  procedure TForm1.btEnviarClick(Sender: TObject);
var
  i: integer;
begin   btEnviar.Enabled := False;
  Screen.Cursor := crHourglass;
  statusBar.Panels[0].Text := 'Aguarde...';
  // anexa os arquivos
  if lbAnexos.Items.Count > 0 then
  begin
    for i:= 0 to lbAnexos.Items.Count -1 do
    TIdAttachment.Create(Mesage.MessageParts, lbAnexos.Items[i]);
  end;
  // email do remetente
  Mesage.From.Name := edtRemet.Text;
  // email do destinatário
  Mesage.Recipients.EMailAddresses := edtDest.Text;
  // assunto do email
  Mesage.Subject := edtAssunto.Text;
  // corpo do email
  Mesage.Body.Text := memoMSG.Lines.Text;   {O ERRO DÁ AQUI>>}  SMTP.Connect();
  try
    SMTP.Send(Mesage);
  finally
    SMTP.Disconnect;
  end;   statusBar.Panels[0].Text := 'Concluído!';
  Screen.Cursor := crDefault;
  btEnviar.Enabled := True;   ERRO ---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EIdOSSLConnectError with message 'Error connecting with SSL.'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help  
---------------------------

Álvaro Luiz

Álvaro Luiz

Responder

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar