0

I'm new to python so take it easy

I have an email script that i've recently wrote, but struggling to add to body or attach an photo to it

Its to become part of a bigger script to take a picture and email to myself when some presses the door bell

my code

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mine.text import MIMEText
from email.mine.image import MIMEImage

Subject = ''
Text = ''

msg = MIMEMultipart()

message = 'Subject: {}\n\n{}'.format(Subject, Text)
msg.attach(MIMEText(message))
mailserver = smtplib.SMTP(host,port_number)
mailserver.ehlo()
mailserver.starttls()
mailserver.ehlo()
mailserver.login(username, password)
mgs = ""
mailserver.sendmail(my_email,their_email,message)

mailserver.quit()

any help would be happily accepted I've tried few tutorials but dont seam to follow same coding path as my original script

many thanks

  • 2
    Possible duplicate of [How to send email attachments?](https://stackoverflow.com/questions/3362600/how-to-send-email-attachments) – NateTheGrate Sep 21 '18 at 12:49
  • I'm not see how that help in this instance - I'd already looked at similar post before asking for help on here – Ash Stirland Sep 21 '18 at 13:59
  • 1
    When an email has a photo, it's done as an 'attachment', so the 'possible duplicate' above shows how you'd attach a photo to the email. – payne Sep 21 '18 at 14:04
  • Are you instead interested in embedding the photo in the email? Can you explain what you've tried? Your code above doesn't even show an attempt to add an image. Please give some more detail that shows you have tried the techniques referenced and not succeeded. There is an answer to that question that deals with images specifically, if you need inspiration. – NateTheGrate Sep 21 '18 at 15:43
  • the other script you have offered references the email in a different way and dont see how i could add that to this script I asked for some help not to be shown up cause I don't know how to do something - I left the days of bullying when i left school ! – Ash Stirland Sep 21 '18 at 21:11

0 Answers0