DICAS

Visite a biblioteca de dicas da comunidade.

Saiba mais

ARTIGOS

Abordagens detalhadas sobre assuntos diversos.

Saiba mais

INICIANTES

Aprenda a programar de um modo simples e fácil.

Saiba mais

DOWNLOADS

Acesse os materiais exclusivos aos membros.

Saiba mais
voltar

erro no envio de email

Visualizando 5 posts - 1 até 5 (de 5 do total)
  • Autor
    Posts
  • #1850
    cleonir
    Participante

    Nesta função da unit UCMail da erro quando vai executar MailRecipients.Append(Email) da um AbstractError;

    Function TMailUserControl.EnviaEmailTp(Nome, Login, USenha, Email,
    Perfil: String; UCMSG: TUCMailMessage): Boolean;
    var
    MailMsg: TAlSmtpClient;

    {$IF CompilerVersion >= 23}
    MailRecipients: TALStrings;
    MailHeader: TALEmailHeader;
    {$ELSE}
    MailRecipients : TStringlist;
    MailHeader : TALSMTPClientHeader;
    {$IFEND}
    begin
    Result := False;
    if Trim(Email) = ” then
    Exit;
    MailMsg := TAlSmtpClient.Create;

    {$IF CompilerVersion >= 23}
    // MailMsg.OnStatus := OnStatus;
    MailRecipients := TALStrings.Create;
    MailHeader := TALEmailHeader.Create;
    {$ELSE}
    MailMsg := TAlSmtpClient.Create;
    MailMsg.OnStatus := OnStatus;
    MailRecipients := TStringlist.Create;
    {$IFEND}

    MailHeader.From := EmailRemetente;
    MailHeader.SendTo := Email;
    MailHeader.ContentType := ‘text/html’;
    MailRecipients.Append(Email); <= //Aqui da o erro
    MailHeader.Subject := UCMSG.Titulo;

    try
    try
    UCEMailForm := TUCEMailForm.Create(Self);
    UCEMailForm.lbStatus.Caption := ”;
    UCEMailForm.Show;
    UCEMailForm.Update;

    MailMsg.SendMail(ServidorSMTP, FPorta, EmailRemetente, MailRecipients,
    Usuario, Senha, fAuthType, MailHeader.RawHeaderText,
    ParseMailMSG(Nome, Login, USenha, Email, Perfil, UCMSG.Mensagem.Text));

    UCEMailForm.Update;
    Result := True;
    except
    on e: Exception do
    begin
    UCEMailForm.Close;
    MessageDlg(e.Message, mtWarning, [mbok], 0);
    raise;
    end;
    end;
    finally
    FreeAndNil(MailMsg);
    FreeAndNil(MailHeader);
    FreeAndNil(MailRecipients);
    FreeAndNil(UCEMailForm);
    end;
    end;

    O que pode ser isso?

    • Este tópico foi modificado 7 anos, 11 meses atrás por cleonir.
    #1852
    InfusTec
    Participante

    Estranho, geralmente o erro “AbstractError” ocorre quando é invocado um método virtual não implementado.

    Vamos tentar verificar a causa da exceção.

    #2192
    Emerson
    Participante

    Estou com o mesmo problema…
    o erro ocorre mais precisamente na unit ucmail

    na função add na linha do getcount

    function TALStrings.Add(const S: AnsiString): Integer;
    begin
    Result := GetCount; //erro aqui
    Insert(Result, S);
    end;

    Usando Delphi Berlin update 2

    #2193
    Emerson
    Participante

    boa tarde.

    fiz algumas alterações na função de envio de email, aparentemente funcionou,
    se puder subir para o git

    Function TMailUserControl.EnviaEmailTp(Nome, Login, USenha, Email,
    Perfil: String; UCMSG: TUCMailMessage): Boolean;
    var
    MailMsg: TAlSmtpClient;

    {$IF CompilerVersion >= 23}
    MailRecipients: TALStringList;
    MailHeader: TALEmailHeader;
    {$ELSE}
    MailRecipients : TStringlist;
    MailHeader : TALSMTPClientHeader;
    {$IFEND}
    begin
    Result := False;
    if Trim(Email) = ” then
    Exit;
    MailMsg := TAlSmtpClient.Create;

    {$IF CompilerVersion >= 23}
    // MailMsg.OnStatus := OnStatus;
    MailRecipients := TALStringList.Create;
    MailHeader := TALEmailHeader.Create;
    {$ELSE}
    MailMsg := TAlSmtpClient.Create;
    MailMsg.OnStatus := OnStatus;
    MailRecipients := TStringlist.Create;
    {$IFEND}

    MailHeader.From := EmailRemetente;
    MailHeader.SendTo := Email;
    MailHeader.ContentType := ‘text/html’;
    MailRecipients.Append(Email);
    MailHeader.Subject := UCMSG.Titulo;

    try
    try
    UCEMailForm := TUCEMailForm.Create(Self);
    UCEMailForm.lbStatus.Caption := ”;
    UCEMailForm.Show;
    UCEMailForm.Update;

    MailMsg.SendMail(ServidorSMTP, FPorta, EmailRemetente, MailRecipients,
    Usuario, Senha, fAuthType, MailHeader.RawHeaderText,
    ParseMailMSG(Nome, Login, USenha, Email, Perfil, UCMSG.Mensagem.Text));

    UCEMailForm.Update;
    Result := True;
    except
    on e: Exception do
    begin
    UCEMailForm.Close;
    MessageDlg(e.Message, mtWarning, [mbok], 0);
    raise;
    end;
    end;
    finally
    FreeAndNil(MailMsg);
    FreeAndNil(MailHeader);
    FreeAndNil(MailRecipients);
    FreeAndNil(UCEMailForm);
    end;
    end;

    #2204

    Olá Emerson. Subidos a sua sugestão de alteração.

    Quando puder, atualize os fontes.

    Desde já agradecemos pela colaboração!

Visualizando 5 posts - 1 até 5 (de 5 do total)
  • Você deve fazer login para responder a este tópico.

Ir ao topo
© 2024 Infus Soluções em Tecnologia - Todos os Direitos Reservados