I can't remember where is nabbed it from, but I use the following: Function Mailer { $emailTo = "" $emailFrom = "" $subject="It's broken, damn it" $smtpserver="" $smtp=new-object System.Net.Mail.SmtpClient($smtpServer) $Message = @" Insert a useful/meaningful message here. "@ } Mailer Last line calls the function (duh for you, but a visitor here might not know).