0

I need to insert all the values (msg_body1, msg_body2, msg_body3) in the line: c=msg_body1.get('1.0',END) How can I do that?

def layout():
    global msg_body1
    msg_label1=Label(f,text='Message+')
    msg_body1=Text(f,height=0,width=35,bd=3)

    global msg_body2
    msg_label2=Label(f,text='Message-')
    msg_body2=Text(f,height=0,width=35,bd=3)

    global msg_body3
    msg_label3=Label(f,text='Message-+')
    msg_body3=Text(f,height=0,width=35,bd=3)


def mail(): 
    try:
       server=smtplib.SMTP('smtp.gmail.com',587)
       server.starttls()
       a=send_email.get()
       b=send_pass.get()
       c=msg_body1.get('1.0',END)
       d=recv_email.get()
       server.login(a,b)
       server.sendmail(a,d,c)
       server.close()

3 Answers 3

1

would this work for you?

def mail(): 
    try:
       server=smtplib.SMTP('smtp.gmail.com',587)
       server.starttls()
       a=send_email.get()
       b=send_pass.get()
       c=msg_body1.get('1.0',END)+msg_body2.get('1.0',END)+msg_body3.get('1.0',END)
       d=recv_email.get()
       server.login(a,b)
       server.sendmail(a,d,c)
       server.close()
Sign up to request clarification or add additional context in comments.

Comments

0

Do you mean something like this

c = f'{msg_body1.get("1.0", END)} {msg_body2.get("2.0", END)} {msg_body3.get("3.0", END)}'

Comments

0

I'd suggest

c = ''.join([
    msg_body1.get('1.0',END),
    msg_body2.get('1.0',END),
    msg_body3.get('1.0',END),
])

1 Comment

join requires an iterable, not separate arguments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.