问题
I went through numerous solutions for this but couldn't replicate for outlook DLs. I have below requirement.
- Create .bat file for testng.xml file and run using task scheduler at any prescribed time. This one I have done.
- Next is to send the testng report to outlook DLs. I am using a remote desktop which is being used by many users.
How can I achieve that? I don't want to use sendEmail.exe file.
Any suggestions please?
Edits:-
1. I tried Send an email(Deprecated) which gives this error :-
An error has occurred for task test. Error message: The following error was reported. The task definition uses a deprecated feature.
2. Using https://mvnrepository.com/artifact/ch.fortysix/maven-postman-plugin/0.1.6 . But for this also some error is coming up.
3. If I am using a server desktop which is being used by other users also. They will be able to see my password for the outlook. How to get rid of this?
回答1:
What you want to do will not work.
You could however just use powershell Send-MailMessage
which comes standard on a windows system by running it in a batchfile:
Note, It must be powershell 2.0 or later.
Send-MailMessage
-From "someone@someserver.net"
-To "whoever@gmail.com"
-Subject "Test email"
-Body "This is a test"
-SmtpServer Some_exhange_server_name\
I broke down the text using newlines for readability, but it should be a single line.
Just create a powershell file called something like sendmail.ps1
and enter the code
Send-MailMessage -From "someone@someserver.net" -To "whoever@gmail.com" -Subject "Test email" -Body "This is a test" -SmtpServer some_exhange_Server_name
additionally, to send mail with an attachment.
Send-MailMessage
-From "someone@someserver.net"
-To "whoever@gmail.com"
-Subject "Test email"
-Body "This is a test"
-SmtpServer Some_exhange_server_name\
-Attachments "c:\my files\file.log"
again in one line as to be used:
Send-MailMessage -From "someone@someserver.net" -To "whoever@gmail.com" -Subject "Test email" -Body "This is a test" -SmtpServer Some_exhange_server_name\ -Attachments "c:\my files\file.log"
来源:https://stackoverflow.com/questions/58373405/how-to-send-email-to-distribution-list-in-outlook-using-task-scheduler