Notify email to users
Hi all
My sytem consist AD, edge, mailbox,hub ( install huhb transport and client access) on windows 2008 64 bit and exchange 2007 sp1 .
Number of users in my company is 3000 users.
At the request of my boss about sending email notices to 300 employees on the list ( from file excel).
How do I send it to multiple people at once?
Please help me
August 13th, 2010 9:47pm
You can use this code:
First test it on couple of email address before you send out to 300 users.
# -----------------------------------------------------
function Release-Ref ($ref) {
([System.Runtime.InteropServices.Marshal]::ReleaseComObject(
[System.__ComObject]$ref) -gt 0)
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()
}
# -----------------------------------------------------
$objExcel = new-object -comobject excel.application
$objExcel.Visible = $True
$objWorkbook = $objExcel.Workbooks.Open("C:\Users\ROCK\Scripts\email.xlsx")
$objWorksheet = $objWorkbook.Worksheets.Item(1)
$intRow = 1
$to = ""
Do {
$to += ',' + $objWorksheet.Cells.Item($intRow, 1).Value()
$intRow++
}
While ($objWorksheet.Cells.Item($intRow,1).Value() -ne $null)
$to = $to.substring(1,$to.length-1)
Write-Host $to
$objExcel.Quit()
$a = Release-Ref($objWorksheet)
$a = Release-Ref($objWorkbook)
$a = Release-Ref($objExcel)
send-mailmessage `
-from "user@domain.com" `
-to $to `
-subject "Subject Text" `
-body "Content" `
-smtpserver hub1 `
the email address should be in the first column without any null values in between.
thanks
ThiyaguThiyagu | MCTS/MCITP - Exchange 2007 | MCSE 2003[Messaging] | http://www.myExchangeWorld.com. This posting is provided "AS IS" with no warranties, and confers no rights.
Free Windows Admin Tool Kit Click here and download it now
August 14th, 2010 7:04am