msg_body = ''
for part in msg.walk():
if part.get_content_type() == "text/plain":
msg_body = part.get_payload(decode=True)
try:
message['Body'] = str(msg_body).decode('utf-8')
except UnicodeDecodeError, UnicodeEncodeError:
message['Body'] = ''
File "C:\emal.py", line 157, in verify_mail
message['Body'] = str(msg_body).decode('utf-8')
UnboundLocalError: local variable 'msg_body' referenced before assignment