Powershell - bulk_mail_sending.ps1

Maillist.csv requires two columns Name and Email

Clear-Host
$FilePath = "C:\x\maillist.csv"
$Getaddress = Import-csv $FilePath
$userid = '[email protected]'
$creds = Get-Credential $userid

Foreach ($Address in $Getaddress) {
    $MailMessage = "<html>
<head>
<meta http-equiv=Content-Type content='text/html; charset=windows-1252'>
<meta name=Generator content='Microsoft Word 15 (filtered)'>
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:'Cambria Math';
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:'Calibri',sans-serif;}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:#954F72;
	text-decoration:underline;}
.MsoChpDefault
	{font-family:'Calibri',sans-serif;}
.MsoPapDefault
	{margin-bottom:8.0pt;
	line-height:107%;}
@page WordSection1
	{size:595.3pt 841.9pt;
	margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
	{page:WordSection1;}
-->
</style>

</head>

<body lang=EN-IE link=blue vlink='#954F72'>

<div class=WordSection1>

<p class=MsoNormal>&nbsp;</p>

<p class=MsoNormal>Hi $($Address.Name),</p>

<p class=MsoNormal>&nbsp;</p>

...
...
...
...
...
...
...
...

<p class=MsoNormal>&nbsp;</p>

</div>

</body>

</html>"


    Send-mailmessage -To $Address.Email -from [email protected] -Credential $creds -subject "x security review - critical info about your x account" -BodyAsHtml -Body $MailMessage -Port 587 -UseSsl -SmtpServer smtp.office365.com
}