1

I want to know how i can attach a pdf to my mail. Sending a mail is not a problem - just the attachement is. So you probably have seen that error before and im already sorry for asking again BUT i literally cant find any solution for this - that works for me. I tried everything i could find for example:

  • Python shortcut with the filename at the end

  • Give the script and the folder admin Privileges

  • Starting my CMD as admin as well

I think that are the most common solutions to the problem but they are not working for me. The following is the code i use. At the open() the problem appears but i think the people that can help me here know how the rest looks anyway. Its pretty basic, i used nothing fancy. Btw downloading an attachement was easy aswell, just sending it is ...

path = "C:/****/.../****"

attachment = open(path, "rb")

Hope you all have a great day!

Max
  • 29
  • 5
  • Here: https://stackoverflow.com/questions/3362600/how-to-send-email-attachments – Atom Feb 05 '20 at 15:58
  • Here: https://stackoverflow.com/questions/3362600/how-to-send-email-attachments – Atom Feb 05 '20 at 15:59
  • Just use this link: https://stackoverflow.com/questions/3362600/how-to-send-email-attachments You could google a bit before asking. > – Atom Feb 05 '20 at 16:00
  • @Atom I already tried that - but nope. Read first please. – Max Feb 05 '20 at 16:03

1 Answers1

0

Have you tried to read the file in your script ?

usually I use attachment = open(r"C:\Users\MyName\Desktop\the_file") to attach a file

Alexall
  • 423
  • 2
  • 12