Seite 2 von 2

Verfasst: Donnerstag 29. Mai 2003, 19:26
von Glamdring
Juchuuuuuuuuuu!!!! :D :D
endlich gehts!!! :idea: :idea:


Danke @ all :D :D

Glamdring

Verfasst: Donnerstag 29. Mai 2003, 20:14
von Glamdring
Doofer Weise hab ich wieder ein Problem :oops: :oops: :oops: :oops:

Den Code zum versenden des Newsletters:

Code: Alles auswählen

"""einlesen und senden"""
import os
import MySQLdb
def send(Text):
    conn = MySQLdb.connect(db="adressen")
    cursor = conn.cursor()
    cursor.execute('select * from adressen')
    all = cursor.fetchall()
    print all
    dat = file("prog.html", "a")
    dat.write("<HTML><BODY>")
    for i in range(len(all)):
        dat.write("<A HREF=\"mailto:")
        cursor.execute('where ID =') # wie schaffe ich es i mit rein  zu bekommen????????????????????
        mail = cursor.fetchall()
        dat.write(mail)
        dat.write("?body=" + text)
        dat.write("\"><BR><BR>")
    dat.write("</BODY></HTML>")
    dat.close()
    os.startfile("prog.html")

text = raw_input("Bitte geben sie den Text ein:")
send(text)
Wie schaffe ich es MYSQl folgenden Code zu übermitteln:
where ID = i ???

Hilfe wäre echt nett
Glamdring

Verfasst: Donnerstag 29. Mai 2003, 20:22
von Dookie
cursor.execute('SELECT * FROM adressen WHERE ID=%s' % (i))

Verfasst: Donnerstag 29. Mai 2003, 20:47
von Glamdring
:oops: :oops: :oops: :oops: :oops: :oops: :oops: :oops: :oops: :oops: :oops: :oops: :oops: :oops: :oops: :oops: :oops:

Manchmal sieht man den Wald vor Bäumen nicht!!!


thx @ Dookie

Verfasst: Donnerstag 29. Mai 2003, 21:08
von Dookie
intgellligenter wäre es aber, gleich die Einträge in der Liste "all" zu verwenden.

Code: Alles auswählen

    for i in range(len(all)):
        dat.write("<A HREF=\"mailto:")
        mail = all[i]
        dat.write(mail)
oder gleich

Code: Alles auswählen

    for mail in all:
        dat.write("<A HREF=\"mailto:")
        dat.write(mail)
Dookie[/code]

Verfasst: Freitag 30. Mai 2003, 18:33
von Glamdring
Hört sich gut an, das übnernehm ich gradmal.

Danke
Glamdring