How to send email using powershell in sharepoint

Advertisement
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

Unknown

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

18 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
  2. The Oscars are here. Which movie will be the big winner when the statuettes are handed out this Sunday, February 24, 2019, starting at 8pm EST?
    Oscars Live
    Oscars 2019
    Oscars 2019 Live
    91st Oscars
    Academy Awards
    Oscar Awards
    Oscars
    Oscars Live
    Oscars 2019
    Oscars 2019 Live
    Academy Awards
    Oscar Awards

    ReplyDelete