$ To = "SomeOtherAddress@whatever.com"
$ Cc = "AThirdUser@somewhere.com"
$ Attachment = "C: usersUsernameDocumentsSomeTextFile.txt"
$ Subject = "Here's the Email Subject"
$ Body = "This is what I want to say"
$ SMTPServer = "smtp.gmail.com"
$ SMTPPort = "587"
Send-MailMessage -From $ From -to $ To -Cc $ Cc -Subject $ Subject -Body $ Body -SmtpServer $ SMTPServer -port $ SMTPPort -UseSsl -Credential (Get-Credential) -Attachments $ Attachment –DeliveryNotificationOption OnSuccess
Step 3: If using Yahoo mail, the server is smtp.mail.yahoo.com and the port is 465 . For Outlook, the server is smtp-mail.outlook.com with port 587 .
Step 4: You can remove Attachment and CC if you don't need them and also delete them in the Send-MailMessage line.
Step 5: Use -UseSsl to make sure email is safe. You can also add -DeliveryNotificationOption OnSuccess if you want to receive confirmation that the message has been sent successfully.
Step 6: When running the command, it will prompt you to enter a username and password (Get-Credential) . Enter this information and your email will be sent.
This is another way to send an email, see the Guide to Email Automatically in Google Sheet with Google Script.
I wish you all success!
See more: