Posts

Showing posts with the label Command Prompt

How to send Email using command in Windows

Image
You can not use Command Prompt directly to send an email, but using PowerShell allows you to use the underlying .Net Framework, you can easily create and send an  e-mail from the command line.  #this works, just sends a simple email $smtpServer = "your.webmailserver.com" $smtpFrom = "fromadress@webmailserver.com" $smtpTo = "todaddress@webmailserver.com" $smtpCc = 'ccdaddress@webmailserver.com' $smtpSubject = "This is a test email" $username = "username" $password = "password" $body = "your mail body goes here" $smtp = New-Object -TypeName "Net.Mail.SmtpClient" -ArgumentList $smtpServer $smtp.Credentials = New-Object system.net.networkcredential($username, $Password); $smtpBody = $body $SMTPMessage = New-Object System.Net.Mail.MailMessage($smtpFrom, $smtpTo, $smtpSubject, $smtpBody) $SMTPMessage.cc.Add($smtpCc) $SMTPMessage.IsBodyHTML=$true $smtp.Send($SMTPMessage) You can run this sc...