Bonjour je cherche ci dessous a l'aide [ loul (StringVar)] a envoyé un mail avec comme destinataire [ TO ] : loul.get() .
si j'execute le script avec une valeur prédéfinit pour [TO] exemple : " lil@hotmail.fr" tout marche .
j'obtiens une erreur de conversion :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/tkinter/__init__.py", line 1475, in __call__
    return self.func(*args)
  File "/Users/sachaterrel/Desktop/Automail.py", line 34, in mail
    BODY = '\r\n'.join(['To: %s' % TO,
TypeError: not all arguments converted during string formatting
Ci dessous le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
31
32
33
34
35
36
37
38
39
def main():
     if LON.get() == "MAIL":
 
           def mail():
               TO = "",loul.get(),""
               SUBJECT = 'TEST MAIL'
               TEXT = 'Here is a message from python.'
 
              # Gmail Sign In
               gmail_sender = ''
               gmail_passwd = ''
 
               server = smtplib.SMTP('smtp.gmail.com', 587)
               server.ehlo()
               server.starttls()
               server.login(gmail_sender, gmail_passwd)
 
               BODY = '\r\n'.join(['To: %s' % TO,
                                   'From: %s' % gmail_sender,
                                   'Subject: %s' % SUBJECT,
                                  '', TEXT])
 
               try:
                   server.sendmail(gmail_sender, [TO], BODY)
                   print ('email sent')
               except:
                   print ('error sending mail')
 
               server.quit()
           top = Toplevel()
           top["bg"]="black"
           top.title("## MAIL ##")
 
           loul= StringVar()
           lol = Entry(top, textvariable = loul , bg="black",fg ="green")
           lol.pack()
 
           B1 = Button(top, bg="black",text=" Valider",command = mail)
           B1.pack()