Hello, I need to send mail to users from powershell, I try to: $SMTPserver = "hub01.corp.net" $from = "admin@corp.net" $to = "user01@corp.main.net" $subject = "Inform You...." $emailbody = "Service unavailable from 10pm to 11pm..." $mailer = New-Object Net.Mail.SMTPclient($SMTPserver) $msg = New-Object Net.Mail.MailMessage($from, $to, $subject, $emailbody) $mailer.send($msg) But how can I specify parameters and get data from CSV file for mass mailing e.g. $to = "user01@corp.main.net" ($_.usersfromcsvfile??? ) $emailbody = "Service unavailable from 10pm to 11pm..." ($_.mailbodyfromcsvfile??? ) What exactly I need to modify in this ps script to get data from Import-CSV ? Thank you. Arman.
import-csv What Can I Do With Windows PowerShell? http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/import-csv.mspx Import-CSV "c:\myfile.csv" | foreach {code-block here, use $_.FieldName for fields from your csv} example: Exchange Server 2007: Bulk creation of mailboxes using Exchange Management Shell http://exchangepedia.com/blog/2006/11/exchange-server-2007-bulk-creation-of.html -- Bharat Suneja Microsoft Corporation blog: exchangepedia.com/blog This posting is provided "AS IS" with no warranties, and confers no rights. Please do not send email directly to this alias. This alias is for newsgroup purposes only. ---------------------------- "Arman Obosyan" <armarn@community.nospam> wrote in message news:37CBA124-2CD9-4A7F-90AC-EA418DEC7D49@microsoft.com... > Hello, > I need to send mail to users from powershell, > I try to: > > $SMTPserver = "hub01.corp.net" > $from = "admin@corp.net" > $to = "user01@corp.main.net" > $subject = "Inform You...." > $emailbody = "Service unavailable from 10pm to 11pm..." > $mailer = New-Object Net.Mail.SMTPclient($SMTPserver) > $msg = New-Object Net.Mail.MailMessage($from, $to, $subject, $emailbody) > $mailer.send($msg) > > > But how can I specify parameters and get data from CSV file for mass > mailing e.g. > $to = "user01@corp.main.net" ($_.usersfromcsvfile??? ) > $emailbody = "Service unavailable from 10pm to 11pm..." > ($_.mailbodyfromcsvfile??? ) > > > What exactly I need to modify in this ps script to get data from > Import-CSV ? > > > Thank you. > > Arman. > > > >
Thanks! Arman Obosyan. "Bharat Suneja [MSFT]" wrote in message news:ussRHjRtIHA.1768@TK2MSFTNGP03.phx.gbl... > import-csv > > What Can I Do With Windows PowerShell? > http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/import-csv.mspx > > Import-CSV "c:\myfile.csv" | foreach {code-block here, use $_.FieldName > for fields from your csv} > > example: > Exchange Server 2007: Bulk creation of mailboxes using Exchange Management > Shell > http://exchangepedia.com/blog/2006/11/exchange-server-2007-bulk-creation-of.html > -- > Bharat Suneja > Microsoft Corporation > blog: exchangepedia.com/blog > > This posting is provided "AS IS" with no warranties, and confers no > rights. Please do not send email directly to this alias. This alias is for > newsgroup purposes only. > ---------------------------- > > "Arman Obosyan" <armarn@community.nospam> wrote in message > news:37CBA124-2CD9-4A7F-90AC-EA418DEC7D49@microsoft.com... >> Hello, >> I need to send mail to users from powershell, >> I try to: >> >> $SMTPserver = "hub01.corp.net" >> $from = "admin@corp.net" >> $to = "user01@corp.main.net" >> $subject = "Inform You...." >> $emailbody = "Service unavailable from 10pm to 11pm..." >> $mailer = New-Object Net.Mail.SMTPclient($SMTPserver) >> $msg = New-Object Net.Mail.MailMessage($from, $to, $subject, $emailbody) >> $mailer.send($msg) >> >> >> But how can I specify parameters and get data from CSV file for mass >> mailing e.g. >> $to = "user01@corp.main.net" ($_.usersfromcsvfile??? ) >> $emailbody = "Service unavailable from 10pm to 11pm..." >> ($_.mailbodyfromcsvfile??? ) >> >> >> What exactly I need to modify in this ps script to get data from >> Import-CSV ? >> >> >> Thank you. >> >> Arman. >> >> >> >> >