Advertisement
In this article we are showing how to read XML file using PowerShell,
this is a sample example based on this we can develop the PowerShell scripts with
config XML file, without touching the code modify the XML config file and send
the mail based on the config file requirement, maintain the XML file will be
very good and easy.
Here is the sample XML file to read the PowerShell for
sending mail with to and from address with Subject and SMTP server information.
Here is the PowerShell code reading the XML file and sending
Mail.
Add-PSSnapin Microsoft.SharePoint.Powershell
[xml]$xmlfile = Get-Content D:\Reading.xml
$EmailFrom =
$xmlfile.mail.mailFrom
$EmailTo =
$xmlfile.mail.mailTo
$EmailSubject =
$xmlfile.mail.mailSubject
$SMTPServer =
$xmlfile.mail.SMTPRelay
$mailmessage = New-Object system.net.mail.mailmessage
$mailmessage.from = ($EmailFrom)
$mailmessage.To.add($EmailTo)
$mailmessage.Subject = $EmailSubject
$mailmessage.IsBodyHTML = $true
$SMTPClient = New-Object
Net.Mail.SmtpClient($SMTPServer)
$SMTPClient.Send($mailmessage)

F5A7E213
ReplyDeleteKırşehir
Aydın
Yozgat
Van
Ordu
Kırıkkale
Gümüşhane
MuÄŸla
Batman
CF41FB3E
ReplyDeleteİçmeler
Payas
Silopi
Bala
Esenkent
Siverek
Döşemealtı
Urla
Avanos
E45C421A
ReplyDeleteDidim
Akyurt
Kozan
Batum
Yüksekova
Odunpazarı
Kızıltepe
Bergama
Girne
EFA165F0
ReplyDeleteOsmangazi
Kozan
Finike
Silopi
Akdeniz
Nazilli
Lapseki
Aktepe
Ortaca