Autor Beitrag
mehmeh
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 97

WIN XP
D5 Prof
BeitragVerfasst: Mo 25.07.05 06:53 
Hilfe!
Hi, ich will E-Mails mit IdMessage und IdSMTP verschicken und hab fogende Fehlermeldung, wenn ich z.B. das Passwort (bei Verbingung zum Server) falsch eingebe.

"Exception der Klasse EIDProtocolReplyError"
"5.7.3. Authentication unsuccessful"

Kann ich die Exception irrgendwie abfangen und es einbauen, dass das Passwort neu abgefragt wir?
Bitte um Hilfe, ich schaff es nicht allein
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 25.07.05 07:08 
Leg eine try - except Block drum rum und behandel im except-Abschnitt die Exception. Alles weitere in der Hilfe.
mehmeh Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 97

WIN XP
D5 Prof
BeitragVerfasst: Mo 25.07.05 07:52 
hm,
so was hatte ich auch im Sinn, aber ich weiß nicht wo das hinkommt.

zur Zeit siehts so aus

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
IdSMTP1.AuthenticationType := atLogin; // entspricht simple Login
 IdSMTP1.Host := host;   // Server angeben
 IdSMTP1.UserName := userID;     // Benutzername
 IdSMTP1.Password := passwort;        // Passwort angeben
 IdSMTP1.Port := 25;            // Port angeben

 IdMessage1.From.text := absmail;    // Absender
 IdMessage1.Sender.text := IdMessage1.From.text; // Absender

 IdMessage1.Recipients.EMailAddresses := Recipient;   // Empfänger
 IdMessage1.CCList.EMailAddresses := CCList;          // Empfänger
 IdMessage1.Subject := sSubject;                      // Betreff

 IdMessage1.Body.Clear;      // den Inhalt des Body löschen
 IdMessage1.Body := Body;    // neue Nachricht in Body laden

 try
   IdSMTP1.Connect;         // Verbindung aufbauen
   IdSMTP1.Send(IdMessage1); // Mail senden
   IdSMTP1.Disconnect;      // Verbindung trennen
   result := true;


ich denk mir das kommt zwischen IdSMTP1.Connect; und IDSMTP.Send(IdMessage);
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Mo 25.07.05 10:57 
Stimmt! Z.b. so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
try  
   IdSMTP1.Connect;         // Verbindung aufbauen  
   IdSMTP1.Send(IdMessage1); // Mail senden  
   IdSMTP1.Disconnect;      // Verbindung trennen  
   result := true; 
except 
   on EIDProtocolReplyError do begin
    ShowMessage('Abbruch: Fehlerhafte Anmeldekennung');
    Exit;
   end;
end;


Gruß,
maxk

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
mehmeh Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 97

WIN XP
D5 Prof
BeitragVerfasst: Mo 25.07.05 11:39 
Danke,

aber jetzt bekomm ich dies

Zitat:
[Fehler] Main.pas(483): Undefinierter Bezeichner: 'EIDProtocolReplyError'


also er kennt´s nicht
schade
Harry M.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: Mo 25.07.05 11:43 
ausblenden Delphi-Quelltext
1:
 Uses IdException					

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
mehmeh Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 97

WIN XP
D5 Prof
BeitragVerfasst: Mo 25.07.05 12:08 
danke das hat geklappt

wie ist das nun wenn ich zwei Exceptions nach einander hab?

könnte das so aussehen?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
try
   IdSMTP1.Connect;         // Verbindung aufbauen
   IdSMTP1.Send(IdMessage1); // Mail senden
   IdSMTP1.Disconnect;      // Verbindung trennen
   result := true;
  except
   on E : Exception do
     begin
      if IdSMTP1.connected then try IdSMTP1.disconnect; except end;
      result := false;
     //  if IdSMTP1.Authenticate then try IdSMTP1.Authenticate; except end;
     //  result := false;
     end;
   on EIDProtocolReplyError do
     begin
      ShowMessage('Abbruch: Fehlerhafte Anmeldekennung');
      Exit;
     end;
  end;


dann hab ich allerdings das problem das er mir das showmessage nicht anzeigt
Harry M.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: Mo 25.07.05 12:25 
Wie wärs mit Nachdenken :roll: Und bis Dir was eingefallen ist kannste meine Procedure verwenden.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
procedure TMain1.CheckAccount(ACCOUNTNAME: String; HOST: string; USERNAME: String; PASSWORD: String);
var
  POP3: TIdPOP3;
begin
  POP3 := TIdPOP3.Create(nil);
  POP3.Host := HOST;
  POP3.Username := USERNAME;
  POP3.Password := PASSWORD;
  Try
  POP3.Connect(-1);
  if POP3.Connected = TRUE then
    if POP3.CheckMessages > 0 then begin
      if SoundCheckBox.Checked then SoundOutput;
      if POP3.CheckMessages = 1 then CoolTrayIcon1.ShowBalloonHint('eMail-Checker ('+ACCOUNTNAME+')', 'Sie haben '+IntToStr(POP3.CheckMessages)+' neue eMail erhalten.', bitInfo, 10);
      if POP3.CheckMessages > 1 then CoolTrayIcon1.ShowBalloonHint('eMail-Checker ('+ACCOUNTNAME+')', 'Sie haben '+IntToStr(POP3.CheckMessages)+' neue eMails erhalten.', bitInfo, 10);
      Main1.CoolTrayIcon1.CycleIcons := TRUE;
      end;
    POP3.Disconnect;
      except
        on e:Exception do begin if E.Message = 'Zeitabstand zwischen zwei Logins unterschritten (FreeMail: 15 min, Club:  kein)/minpoll timelimit' then showmessage('zeitlimit!!'); end;
        on E:EIdSocketError do begin { nothing to do !! } end;
        on E:EIdProtocolReplyError do begin MessageDlg('Falsche Angabe der Benutzerkennung für das eMailkonto: '+ACCOUNTNAME, mtError, [mbok], 0);end;
        on E:EIdConnClosedGracefully do begin { nothing to do !! } end;
    end;

  POP3.Free;
end;


Bei
ausblenden Delphi-Quelltext
1:
on e:Exception do begin if E.Message = 'Zeitabstand zwischen zwei Logins unterschritten (FreeMail: 15 min, Club:  kein)/minpoll timelimit' then showmessage('zeitlimit!!'); end;					

ist grad noch Baustelle. Bin noch nicht dazugekommen das mal zu machen. Anderes is mir grad wichtiger. Das Prinzip eine bestimme Melung, nebst anderer Meldung zubehandeln sollte aber klar sein.

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Mo 25.07.05 12:34 
Alles geht nicht! Da die IdExceptions von Exception abgeleitet sind, wird Delphi den Zweig mit on Exception immer betreten (selbst bei EAbort - also beim Aufruf von Abort;). Entweder man setzt die Reihenfolge im Quellcode günstiger, also so, dass die Exception als letztes vorkommt oder man arbeitet mit den Exceptions also Objekte:
ausblenden ungetesteter Code
1:
2:
3:
4:
5:
6:
7:
8:
9:
on E:Exception do begin
 if E.ClassNameIs('EIDProtocolReplyError') then begin
  {...}
 end else if E.ClassNameIs('EAbort') then begin
  {...}
 end else begin
  {...}
 end;
end;


Gruß,
maxk

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
Harry M.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: Mo 25.07.05 13:00 
:oops: habe auch jetzt erst gesehen das Du welche verschicken - nicht auf neue Prüfen oder Abholen. Sorry. Aber so ist das wenn man ausm Bett springt und als erstes - mit noch völlig verklebten Augen - erstmal beim DF vorbeischauen muss.

Immer diese Zwangshandlungen :lol:

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
mehmeh Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 97

WIN XP
D5 Prof
BeitragVerfasst: Di 26.07.05 08:36 
Hi, also danke euch allen

ich war ja blind. E : Exception ist ja für alle Exception egal welche.

Ich hab es jetzt erstmal so gelöst, bis ich weiß was bei mir noch für Fehler auftreten können.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
try
   begin
   IdSMTP1.Connect;         // Verbindung aufbauen
   IdSMTP1.Send(IdMessage1); // Mail senden
   IdSMTP1.Disconnect;      // Verbindung trennen
   result := true;
   end;
  except
   on E : Exception do      // fängt alle Fehler ab 
     begin
      if IdSMTP1.connected then
       begin
         IdSMTP1.disconnect;
         MessageDlg('Abbruch: Fehlerhafte Anmeldekennung', mtError, [mbOK], 0);
         Exit;
        end;
       result := false;
 end;
 end;
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Di 26.07.05 12:52 
Warum machst du es nicht so, wie ich in meinem letzten Posting vorgeschlagen habe? Dann weisst du, ob die Anmeldung fehlerhaft war, ob der Server nicht erreichbar ist, etc.

Gruß,
maxk

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.