$pass = Get-StoredCredential -Target 'domain.in'
Send-MailMessage -UseSsl -Credential $pass -From 'sender mail` -To 'receiver mail' -Subject 'test1' -Body 'tst' -Attachments 'C:\Users\V-Connect-Akash\Downloads\test.txt' -SmtpServer 'smtp.office365.com'type here
So this script retrieves the credentials stored in windows credential manager and authenticated it with the smtpserver. When I run this script manually I don't see any error I receive mail without any error. But when I run same script with task scheduler I get error "Authentication failed because the remote party has closed the transport stream".
Is there something that I need t take care of before running this script using task scheduler.