I can't get this python script to run. Help!

I can’t get my python script to work. As far as i know microsoft outlook allows scripting. Im new to this and i was using chatgpt so dont bash me. Looking for help to determine why this script didn’t work? i will of course block out the password to my script here but in the script its in the script. Any help would be greately appreciated! Im running the script from my command prompt and i was connected to the internet. Again, first time doing this so don’t make fun.

import smtplib

Email configuration for Outlook

smtp_server = ‘smtp.live.com
smtp_port = 587
sender_email = ‘cosmicpiratehav0ck@outlook.com’ # Your Outlook email address
sender_password = ‘blank’ # Your Outlook password
receiver_email = ‘cosmicpiratehav0ck@outlook.com’ # Recipient’s email address

Get user feedback

user_feedback = input("Enter your feedback: ")

Create and send the email

try:
server = smtplib.SMTP(smtp_server, smtp_port)
server.starttls()
server.login(sender_email, sender_password)

subject = 'Feedback'
body = user_feedback

msg = f'Subject: {subject}\n\n{body}'

server.sendmail(sender_email, receiver_email, msg)
print("Feedback sent successfully!")

except Exception as e:
print(f"An error occurred: {str(e)}")
finally:
server.quit()

Please read this About the Python Help category so that you know how to format your code for us to read and help you.

1 Like

I can do that later but the code is working, the question is more of what am i doing wrong that the script is not working which i dont think its code related.

No, you cannot; we can only possibly help understand what is wrong with the code that you wrote, if we can actually figure out what code you wrote. Indentation is crucial in Python; proper formatting is necessary so that we can see that indentation and verify that the structure of the code makes sense.

This doesn’t make any sense. “the script” is “the code”.

ChatGPT can not write code for you. It is essentially making things up. It does not reason; it only has a very complicated model for what “words” go together (including symbols like =). It is effectively a story-teller, not a programmer.

Anyway, “it doesn’t work” is not a diagnosable problem. In order to get help with any kind of code from anyone who knows what they’re talking about, you need to be able to show specifically what did happen, specifically what you expected to happen instead, and how that is different.

There is a deeper problem here, however: if you take a defensive stance and keep saying “I’m a beginner, this is my first time, don’t make fun” then that makes people not want to interact with you. It makes you come across as someone that will take offense too easily. The computer does not care about your feelings; it has no idea you exist. This is a help forum and everyone knows that there are beginners here all the time, and is practiced in explaining things at a basic level. But we have to know what to explain first.

1 Like

The script is supposed to create an ai bot that gets feedback from the user. The user imput i simulated by typing in the input a fictitious input feedback, the code is suppose to access my microsoft outlook email, log i. And send myself an email with the feedback input i provided. All its doing is just printing the feedback on the command prompt but not loggin into my email and sending the email with the input feedback.