Autor Beitrag
F.Art
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 434



BeitragVerfasst: So 03.11.02 18:51 
Ich habe mir ein eMail Newsletter geproggt nur das mit dem auslesen der Lsitbox funzt nicht. Ich haffe doch mir kann geholfen werden. Ich bekomme so aber immer die Meldung (List index out of bounds 32231).
ausblenden 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:
procedure TForm1.SendenClick(Sender: TObject);
var
i : word;
begin
Stop.Enabled:=true;
Senden.Enabled:=false;
    SmtpCli.AuthType     := smtpAuthLogin;
    smtpcli.Host         := SMTPServer.Text;
    smtpcli.Username     := Username.Text;
    smtpcli.Password     := Passwort.Text;
    smtpcli.RcptName.Clear;
    smtpcli.RcptName.Add(ABO.Text);
    smtpcli.FromName     := AbsenderEmail.Text;
    smtpcli.HdrFrom      := (AbsenderName.Text)+'<'+(AbsenderEmail.Text)+'>';
    smtpcli.MailMessage.Add(Nachricht.Text);
    smtpcli.HdrTo        := ABOListe.Items.Strings[i-1];
    smtpcli.HdrReplyTo   := AbsenderEmail.Text;
    smtpcli.HdrSubject   := Betreff.Text;
    smtpcli.Open;
    delay(1000);
    smtpcli.Mail;
    delay(1000);
    smtpcli.Quit;
    delay(3000);
showmessage('Newsletter versendet.');
end;
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: So 03.11.02 19:02 
Hi,

bei dieser Zeile
ausblenden Quelltext
1:
  smtpcli.HdrTo    := ABOListe.Items.Strings[i-1];					

kommt es wohl zu einem Fehler. Denn die Variable I wird in Deinem geposteten Code nicht mit einem gültigen Wert beschrieben.

Gruß
TINO
F.Art Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 434



BeitragVerfasst: So 03.11.02 19:10 
Titel: variable
Ich kenne mich nicht mit variablen so aus.
Wie bekomme ich das hin?
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: So 03.11.02 21:08 
Du solltest doch eigentlich wissen was Du da geschrieben hast :?

Wenn ich mir die Einrückungen in Deinem Quelltext ansehe scheint es mir so als würde dort eine FOR-NEXT-Schleife fehlen.

Versuch mal folgendes:
ausblenden 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:
28:
29:
procedure TForm1.SendenClick(Sender: TObject);
var
i : word;
begin
Stop.Enabled:=true;
Senden.Enabled:=false;
For i := 1 To ABOListe.Items.Count Do
Begin
  SmtpCli.AuthType   := smtpAuthLogin;
  smtpcli.Host     := SMTPServer.Text;
  smtpcli.Username   := Username.Text;
  smtpcli.Password   := Passwort.Text;
  smtpcli.RcptName.Clear;
  smtpcli.RcptName.Add(ABO.Text);
  smtpcli.FromName   := AbsenderEmail.Text;
  smtpcli.HdrFrom   := (AbsenderName.Text)+'<'+(AbsenderEmail.Text)+'>';
  smtpcli.MailMessage.Add(Nachricht.Text);
  smtpcli.HdrTo    := ABOListe.Items.Strings[i-1];
  smtpcli.HdrReplyTo  := AbsenderEmail.Text;
  smtpcli.HdrSubject  := Betreff.Text;
  smtpcli.Open;
  delay(1000);
  smtpcli.Mail;
  delay(1000);
  smtpcli.Quit;
  delay(3000);
End;
showmessage('Newsletter versendet.');
end;
F.Art Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 434



BeitragVerfasst: So 03.11.02 22:25 
Titel: ---
Da kommt die selbe Meldung aber wenn ich die eine Zeile (smtpcli.HdrTo := ABOListe.Items.Strings[i-1];) verschiebe direkt mit unter Begin dann sendet er nur 1 email.
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: So 03.11.02 23:03 
Hallo F.Art,

ich war mal so frei und habe den Code etwas optimiert.
ausblenden 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:
28:
29:
30:
procedure TForm1.SendenClick(Sender: TObject); 
var 
i : word; 
begin 
Stop.Enabled:=true; 
Senden.Enabled:=false; 
  SmtpCli.AuthType   := smtpAuthLogin; 
  smtpcli.Host     := SMTPServer.Text; 
  smtpcli.Username   := Username.Text; 
  smtpcli.Password   := Passwort.Text; 
  smtpcli.RcptName.Clear; 
  smtpcli.RcptName.Add(ABO.Text); 
  smtpcli.FromName   := AbsenderEmail.Text; 
  smtpcli.HdrFrom   := (AbsenderName.Text)+'<'+
                                 (AbsenderEmail.Text +'>'; 
  smtpcli.MailMessage.Add(Nachricht.Text);
  smtpcli.HdrReplyTo  := AbsenderEmail.Text; 
  smtpcli.HdrSubject  := Betreff.Text;  
For i := 0 To ABOListe.Items.Count-1 Do 
Begin 
  smtpcli.HdrTo  := ABOListe.Items.Strings[i]; 
  smtpcli.Open; 
  sleep(1000); 
  smtpcli.Mail; 
  sleep(1000); 
  smtpcli.Quit; 
  sleep(3000); 
End; 
showmessage('Newsletter versendet.'); 
end;



Der Fehler (.. out of Bounds) kam wohl zustande, weil I den wert Null hatte und du ein das Item (i-1) der ListBox angesprochen hast. Da "-1" keine gültige Bezeichnung ist, kam es zu einem Fehler.

_________________
If accidentally read, induce vomitting.
F.Art Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 434



BeitragVerfasst: Mo 04.11.02 01:06 
Titel: ----
Danke es läuft so.
Da hätte ich noch ne Frage. Ich benutze die ICS Kombonente und habe immer ein delay eingebaut da sonst immer die Meldung kommt component nicht bereit.
Jetzt meine Frage kann man das nicht so machen das er automatisch aim open,mail und dann quit geht wen die kombo dann bereit ist?
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mo 04.11.02 09:08 
F.Art hat folgendes geschrieben:
Da hätte ich noch ne Frage.

Bitte die Frage in die Sparte Internet / Netzwerk posten!

Gruß
TINO
Dieses Thema ist gesperrt, Du kannst keine Beiträge editieren oder beantworten.

Das Thema wurde von einem Team-Mitglied geschlossen. Wenn du mit der Schließung des Themas nicht einverstanden bist, kontaktiere bitte das Team.