How to send email using powershell in sharepoint

Advertisements
Here we can see the script,the way we can sent mail alerts using power shell

$EmailFrom = "FromEmail@domain.com"
$EmailTo = "ToEmail@domain.com"
$SMTPServer = "YourSmtpServerName"
$EmailSubject = "Enter your Subject you want"

$mailmessage = New-Object system.net.mail.mailmessage
$mailmessage.from = ($EmailFrom)
$mailmessage.To.add($EmailTo)
$mailmessage.Subject = $EmailSubject
$mailmessage.Body = "Email body"
#if we are sending any html body we have to use below line
$mailmessage.IsBodyHTML = $true
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer)
#if you want any network credentials set user name and password.
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("username", "password");
$SMTPClient.Send($mailmessage)

SharePoint Online Real Time Training Contact: JLAKSHMITULASI@GMAIL.COM
Advertisements
SHARE

lakshmitulasi Jasti

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

8 comments:

  1. Grexit is the best solution to share, store and manage emails. They are the pioneer provider in business email management.
    http://800supportnet.deviantart.com/art/The-Best-Ways-To-Change-Gmail-Password-620293105?ga_submit_new=10%253A1467952806

    ReplyDelete