Skriptimiskeeled aine aruanded 2010 sügis/SigmarMuuga/Poweshell: Difference between revisions
From ICO wiki
Jump to navigationJump to search
Created page with '=Sigmar Muuga Poweshelli asjad=' |
mNo edit summary |
||
(3 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
=Sigmar Muuga Poweshelli asjad= | [[Category: Skriptimiskeeled]] | ||
==Sigmar Muuga Poweshelli asjad== | |||
===Skript, mis saadab e-maili=== | |||
<source lang="powershell"> | |||
# Skripts, mis kysib interaktiivselt parameetrid ja saadab vastavalt sisestatud andmetele e-maili | |||
# Autor: Sigmar Muuga DK31 | |||
$emailFrom = Read-Host "Kellelt saadad e-maili?" | |||
Write-Host "E-maili saatja on $emailFrom" | |||
$emailTo = Read-Host "Kellelel saadad e-maili" | |||
Write-Host "E-mail saadetakse aadressile: $emailTo" | |||
$subject = Read-Host "E-maili teema:" | |||
Write-Host "E-maili teema on: $subject" | |||
$body = Read-Host "Kirja sisu:" | |||
Write-Host "Kirja sisuks on: $body" | |||
$smtpServer = Read-Host "SMTP serveri aadress:" | |||
Write-Host "SMTP serveriks on: $smtpServer" | |||
Write-Host "Saadame e-maili..." | |||
$smtp = new-object Net.Mail.SmtpClient($smtpServer) | |||
$smtp.Send($emailFrom, $emailTo, $subject, $body) | |||
Write-Host "E-mail saadetud!" | |||
</source> |
Latest revision as of 09:46, 13 May 2011
Sigmar Muuga Poweshelli asjad
Skript, mis saadab e-maili
# Skripts, mis kysib interaktiivselt parameetrid ja saadab vastavalt sisestatud andmetele e-maili
# Autor: Sigmar Muuga DK31
$emailFrom = Read-Host "Kellelt saadad e-maili?"
Write-Host "E-maili saatja on $emailFrom"
$emailTo = Read-Host "Kellelel saadad e-maili"
Write-Host "E-mail saadetakse aadressile: $emailTo"
$subject = Read-Host "E-maili teema:"
Write-Host "E-maili teema on: $subject"
$body = Read-Host "Kirja sisu:"
Write-Host "Kirja sisuks on: $body"
$smtpServer = Read-Host "SMTP serveri aadress:"
Write-Host "SMTP serveriks on: $smtpServer"
Write-Host "Saadame e-maili..."
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject, $body)
Write-Host "E-mail saadetud!"