jump to navigation

Send Mail Power Shell March 6, 2018

Posted by juanpablo1manrique in SharePoint.
Tags: ,
add a comment

SharePoint 2013 Management Shell – SharePoint 2010 Management Shell
$sd = new-object System.collections.specialized.stringdictionary
$sd.add(“to”,”uncorreodest@undominio.co”)
$sd.add(“from”,”unorigen@undominioorg.com”)
$sd.add(“Subject”,”The clue is in the name!”)
$web = get-spweb “http://misharepoint/”
$body = “This is our body<br/> We can use <strong>HTML</strong> codes in it.”
[Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($web,$sd,$body)

 

Windows Power Shell 1
Send-MailMessage -To “uncorreodest@undominio.co” -From “unorigen@undominioorg.com” -Subject “Test mail” -Body “Body aaaa” -SmtpServer “smtp.unorigen.com”

Windows Power Shell 2

$message=new-object Net.Mail.MailMessage;
$message.From=”unorigen@undominioorg.com”;
$message.To.Add(“uncorreodest@undominio.co”);
$message.Subject=”subjecttexthere…”;
$message.Body=”bodytexthere…”;
$smtp=new-object Net.Mail.SmtpClient(“smtp.unorigen.com”,”25″);
$smtp.EnableSSL = $false;
$smtp.Credentials = New-Object System.Net.NetworkCredential(“undominio\unusuario”, “*************”);
$smtp.send($message);