0

The below code snippet sends email with status. If I want to add another line break with text as Sent from Scheduler. What could be the possible way ?

def send_email(status,message):
    date = str(datetime.now().date())[-5:].replace('-', '/')
    yag.send(to=TO_EMAIL,subject="{} Rebuild Code: {}".format(date, status),contents=message)
    logging.info("Mail Sent!")

Thanks!

Hari Krishnan
  • 2,049
  • 2
  • 18
  • 29
user852986
  • 15
  • 4

1 Answers1

0

Please try this updated code.

Update:

def send_email(status,message):
    date = str(datetime.now().date())[-5:].replace('-', '/')
    message = "{}\n{}".format(message, 'Sent from Scheduler'
    yag.send(to=TO_EMAIL,subject="{} Rebuild Code: {}".format(date, status),contents=message))
    logging.info("Mail Sent!")

Here, instead of just returning the message, it can be updated as "{}\n{}".format(message, 'Sent from Scheduler') \n is the single line break. If you want multiple line breaks you can use \n\n.

yogkm
  • 649
  • 5
  • 15
  • contents=message cannot be removed as it posts the Message inside the email content. I want to add one more line & do not want to edit or remove the existing. – user852986 Sep 21 '18 at 05:04
  • I've updated the code. Just try to print `message` before `yag.send` to see what it prints. – yogkm Sep 21 '18 at 05:10
  • Looking at the code seems it will mostly print: Sent from Scheduler. The purpose was to add this line not to replace the existing message lines. – user852986 Sep 21 '18 at 06:18