1

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?

  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.

  1. Using https://mvnrepository.com/artifact/ch.fortysix/maven-postman-plugin/0.1.6. But for this also some error is coming up.

  2. 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?

TylerH
  • 20,799
  • 66
  • 75
  • 101
avidCoder
  • 440
  • 2
  • 10
  • 28
  • If you want us to help you to fix one of the numerous solutions, then you'll need to edit your question to include that solution. – Compo Oct 14 '19 at 09:11
  • @GerhardBarnard - Can you send me the exact link?.. I can go through to implement this. – avidCoder Oct 14 '19 at 09:14
  • Yes. Give me sometime. Will update the question. – avidCoder Oct 14 '19 at 09:20
  • An error message alone is of little use, please post the actual code you've written which returns that message! – Compo Oct 14 '19 at 09:47
  • This is not the error which I received from any code. When we use Task Scheduler functionality of windows. We have option for Send mail (Deprecated). When I used this, then the above error pops up. https://www.netwoven.com/wp-content/uploads/2014/09/image2.jpg – avidCoder Oct 14 '19 at 09:58

1 Answers1

2

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"

In Task Scheduler, Edit Action, for the "Program/Script" you browse to:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

the "Add arguments (optional)" will be:

-file sendmail.ps1

and "Start in (optional)" will be the folder of your ps1 file.

Roland
  • 4,619
  • 7
  • 49
  • 81
Gerhard
  • 22,678
  • 7
  • 27
  • 43
  • I tried the above code. Since, I am using the server desktop. What value shall I put in From? And this desktop doesn't have outlook also. – avidCoder Oct 14 '19 at 10:06
  • Send-MailMessage -From "avidcoder.demo@test.com" -To "team@test.com" -Subject "Test email" -Body "This is a test" -SmtpServer smtp-mail.outlook.com – avidCoder Oct 14 '19 at 10:08
  • This is the error which I am getting :- Send-MailMessage : Unable to connect to the remote server At line:1 char:1 + Send-MailMessage -From "avidcoder.demo@test.com" -To "team@tes ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpExcept ion + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage – avidCoder Oct 14 '19 at 10:11
  • For gmail .. it is fine. But for outlook office365. I am facing issue. May be I am not providing the correct SMTP server name. Will get back to you after discussing with the team. – avidCoder Oct 14 '19 at 10:22