Runbook Not Processing Emails Correctly

Abdulaziz Yassin 0 Reputation points
2025-05-07T09:12:31.7766667+00:00

The runbook is not processing all emails as expected, even when the volume of emails is lower than usual. What steps can be taken to troubleshoot this issue?

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,366 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Madugula Jahnavi 495 Reputation points Microsoft External Staff Moderator
    2025-05-21T11:48:37.4266667+00:00

    Hello Abdulaziz Yassin,

    The issue is with the runbook python script you are trying to execute. Because I have tested with couple of runbooks and it worked fine as expected.

    Can you try below sample code once if this is sending emails correctly.

    
    import smtplib
    
    from email.mime.text import MIMEText
    
    def send_email(to_address, subject, body):
    
    msg = MIMEText(body)
    
    msg['Subject'] = 'subject'
    
    msg['From'] = '<mailid>'
    
    msg['To'] = to_address
    
    with smtplib.SMTP('smtp.office365.com', 587) as server:
    
        server.starttls()
    
        server.login('******@domain.com', 'password')
    
        server.sendmail(msg['From'], [msg['To']], msg.as_string())
    
    

    If this is helpful, please click on Accept Answer and upvote it. If you still have any queries further, please click on comment.


  2. Abdulaziz Yassin 0 Reputation points
    2025-06-10T10:47:19.12+00:00

    Thanks for following upp, we tested the code shared by you and this is the result:

    User's image


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.