How to send email to distribution list in outlook using task scheduler?

拜拜、爱过 提交于 2020-05-14 09:13:33

问题


I went through numerous solutions for this but couldn't replicate for outlook DLs. I have below requirement.

  1. Create .bat file for testng.xml file and run using task scheduler at any prescribed time. This one I have done.
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!