muquit / mailsend

A program to send mail via SMTP from command line
Other
294 stars 68 forks source link

Use of mailsend with powershell #73

Closed rtg20 closed 9 years ago

rtg20 commented 9 years ago

Hi I am sending e-mail using mailsend 1.17b15 from a powershell script.

Start-Process -FilePath 'C:\Email\mailsend1.17b15.exe' -ArgumentList $myargs

but the argument list includes -msg-body

-msg-body "C:\Email\message.txt"

I am generating message.txt from a MSSQL database. As soon as the e-mail is sent, I delete message.txt and loop onto the next MSSQL result.

The problem is, i have to insert a 10 second pause in between the Start-Process line and deleting the message.txt file. Otherwise mailsend doesn't work. I guess Powershell moves onto the delete line whilst mailsend is authenticating so the message.txt has gone by the time mailsend needs it.

is there a more elegant way to fix this than the 10 second pause?

thanks!

rtg20 commented 9 years ago

...ok I think I fixed it by adding

-Wait

to the powershell command.

will close this - hope it helps some people.

thanks!