# Required parameters $smtpServer # SMTP server hostname / IP address $emailFrom # Sender (some SMTP servers require a valid local address) $emailRcpt # Recipient (comma seperated if multiple) $emailSubject # Email subject line $msgBody # Email body $FilePath # Path to attachment file $domain # Network domain $username # Network username $password # Network password # Create required objects... $smtp = New-Object Net.Mail.SmtpClient -arg $smtpServer $msg = New-Object Net.Mail.MailMessage $attach = New-Object Net.Mail.Attachment($FilePath) $cred = new-object System.net.networkCredential # Populate mail message... $msg.From = $emailFrom $msg.To.Add($emailRcpt) $msg.Subject = $emailSubject $msg.IsBodyHTML = $true $msg.Body = $msgBody $msg.Attachments.Add($attach) # Provide credentials to SMTP client $cred.domain = "the domain you want" $cred.userName = "username" $cred.password = "password" $smtp.credentials = $cred # Send... $smtp.Send($msg)
Selasa, 22 April 2014
PowerShell SMTP
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar