If you want to send email from PowerShell script via Google Mail:
$SMTPServer = "smtp.gmail.com" $SMTPPort = "587" $SMTPUsername = "sender@gmail.com" $SMTPPassword = "password" $EmailSenderAddress = New-Object System.Net.Mail.MailAddress("sender@gmail.com", "PowerShell Automated Email") $EmailFrom = $EmailSenderAddress $EmailTo = "recipient@gmail.com" $EmailCc = "recipient@hotmail.com" $EmailAttachment = "C:\Scripts\Attachment.txt" $EmailSubject = "Automated Email with Report." $EmailBody = @" Please find attached report. "@ $EmailMessage = New-Object System.Net.Mail.MailMessage $EmailMessage.Subject = $EmailSubject $EmailMessage.Body = $EmailBody $EmailMessage.To.Add($EmailTo) $EmailMessage.CC.Add($EmailCc) $EmailMessage.From = $SMTPUsername $EmailMessage.Attachments.Add($EmailAttachment) $SMTPSession = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort); $SMTPSession.EnableSSL = $true $SMTPSession.Credentials = New-Object System.Net.NetworkCredential($SMTPUsername, $SMTPPassword); $SMTPSession.Send($EmailMessage) Write-Host "Mail Sent"