Demo:

the mail received from powershell sent:

PowerShell
Edit|Remove
$comments = @'
author:fuhj(powershell@live.cn ,http://txj.shell.tor.hu)
example:
send-mail -toAddress user@domain.com -subject "Powershell Testing Mail " -body "This is a test mail form powershell" -file "C:\powershellmailfile.txt"
-toName -body and -file are all optional.
use double quotes for the name parameters ie; -body "Proper Content"
'@
function send-mail{
	param(
	     [string]$toAddress   = $(throw "toAddress must be set")
	    ,[string]$Subject     = $(throw "subject must be set")
	    ,[string]$body        = ""
	    ,[string]$file        = "")
#mail server configuration
	$smtpServer   = "smtp.live.com"
	$smtpUser     = "powershell@live.cn"
	$smtpPassword = "P@ssWord"
	$sslNeed      =$true #SMTP server needs SSL should set this attribute
	$MailAddress  ="powershell@live.cn"
	$fromName     = "fuhj"
	$replyTo      = "powershell@live.cn"
#create the mail message
	$mail = New-Object System.Net.Mail.MailMessage
#set the addresses
	$mail.From = New-Object System.Net.Mail.MailAddress($MailAddress,$fromName)
	$mail.To.Add($toAddress)
#set the content
	$mail.Subject = $Subject
	$mail.Priority  = "High"
	$mail.Body = $Body
	$filename= $file
	$attachment = new-Object System.Net.Mail.Attachment($filename)
	$mail.Attachments.Add($attachment)
#send the message
	$smtp = New-Object System.Net.Mail.SmtpClient -argumentList $smtpServer
	$smtp.Credentials = New-Object System.Net.NetworkCredential -argumentList $smtpUser,$smtpPassword
	$smtp.EnableSsl = $sslNeed;
	try{
		$smtp.Send($mail)
		echo 'Ok,Send succed!'
	}
	catch 
	{
		echo 'Error!Filed!'
	}
}