RealisticMagician
RealisticMagician

Reputation: 37

Azure Automation SMTP remote name could not be resolved

I have a powershell script that will get all of my azure app registration information and send the information out in an email. I have the powershell working on my laptop, but can't get the email to send out in Azure Automation.

This is the error I get in Azure Automation. I replaced my smtp server name. There is an actual server not that value. All of my variables are filled. Again, this is working on my laptop using the exact same script in Automation.

The remote name could not be resolved: 'smtpserver'

Here is the snippet of code for it

#Send Email
    $Style = "<style>BODY{font-family: Arial; font-size: 10pt;}"
    $Style += "TABLE{border: 1px solid black; border-collapse: collapse;}"
    $Style += "TH{border: 1px solid black; background: #D8D8D8; padding: 5px; }"
    $Style += "TD{border: 1px solid black; padding: 5px; }"
    $Style += "</style>"

    $Html = ''
    $Html += "<div>These application security items are expiring in $($ExpiresInDays) days</div>"
    $Html += "<br></br>"
    $Html += $ExpiringTable | ConvertTo-Html -Head $Style
    $html += "<br></br>"
    $Html += "For troubleshooting this email, the automation for this can be found at this location: "
    $Html += "<a href="+ $($AutomationLink) +">Azure Portal: Expiring Security Items</a>"

    Send-MailMessage -SmtpServer $SmtpServer -From $EmailFrom -To $EmailTo -Subject $Subject -Body $Html -BodyAsHtml -Priority $Priority -ErrorAction Stop

Upvotes: 0

Views: 304

Answers (1)

KrishnaG
KrishnaG

Reputation: 3484

The recommended way to send email from Azure Automation runbook is using SendGrid. For more information, please refer this Azure document.

Upvotes: 0

Related Questions