#navi(../)
* PowerShellでメールを送信するサンプルコード [#n55f7531]
PowerShellでメールを送信するサンプルコードを以下に記します。
#contents
#htmlinsertpcsp(win-top.html,win-sp.html)
* メールの送信 [#z53e1efd]
単純なメール送信サンプルコードになります。
$smtp = "smtp" # SMTPサーバ
$port = 25 # SMTPポート
$from = "from@domain"
$to = "to@domain"
$body = "メール本文"
$SmtpClient = New-Object Net.Mail.SmtpClient($smtp,$port)
$Message = New-Object Net.Mail.MailMessage($from, $to, $subject, $body)
$SmtpClient.Send($Message)
* HTMLメールの送信 [#i940288f]
単純なHTMLメール送信サンプルコードになります。
$smtp = "smtp" # SMTPサーバ
$port = 25 # SMTPポート
$from = "from@domain"
$to = "to@domain"
$body = "<b>メール本文</b>"
$SmtpClient = New-Object Net.Mail.SmtpClient($smtp,$port)
$Message = New-Object Net.Mail.MailMessage($from, $to, $subject, $body)
$Message.IsBodyHtml = $True
$SmtpClient.Send($Message)
以上、PowerShellでメールを送信するサンプルコードでした。
#htmlinsertpcsp(win-btm.html,win-sp.html)