0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

AzureのRunBook(PowerShell)からSendGridを利用してメール送信する

Last updated at Posted at 2021-09-13

Azureで無料のSendGridのアカウントを作成する

よく纏められたサイトがあったのでそちらで作成してみてください。

資格情報を作成する

項目名 設定値の説明 入力例 
名前    任意の名前                     SendGridAccount
ユーザ名  SendGridアカウント?メアド?迷わず固定で入力   apikey
パスワード APIを作成した時に1度しか表示されないパスワード    ***

 

資格情報作成時のイメージ
認証情報.PNG

SendGridサイトでのAPIKey作成時のイメージ
(パスワードはこのタイミングで1度だけしか表示されないので控えておく)
APIKeyの発行.PNG

Runbookを作成する

RunBook作成時のイメージ

runbookの作成.PNG

PowerShellコード部分をシンプルに記載する


$SmtpCredential = Get-AutomationPSCredential -Name "SendGridAccount"

Send-MailMessage    -To "宛先のメールアドレス" `
                    -Subject "件名" `
                    -Body "from sendgrid ..." `
                    -UseSsl -Port 587 `
                    -SmtpServer "smtp.sendgrid.net" `
                    -From "発信元のメールアドレス" `
                    -Encoding ([System.Text.Encoding]::UTF8) `
                    -Credential $SmtpCredential

【今回躓いたところ】

・ SendGridのアカウントを作成する手順で、アカウント設定したメールアドレスに確認メールが届きますが、迷惑メールボックスに入っていて気付きませんでした。

・ 資格情報のユーザ名で迷いました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?