Open muquit opened 10 years ago
I've managed to implement a workaround for this until this requested feature has been implemented.
Add the following to the end of your batch script:
:EmailSub
SetLocal ENABLEDELAYEDEXPANSION
mailsend.exe
When you need to send an email in your batch script, use this command: Call :EmailSub
If you have variables in your script that are used when sending the email, you would use: Call :EmailSub %var1% %var2% %var3%
You then use those variables by writing: %1 %2 %3 ...within the subroutine.
Does it retry by attempts? For instance a configuration variable should have to have the number of attempts to retry instead of a timeout measurement. Max should be 5.
I've managed to implement a workaround for this until this requested feature has been implemented. Add the following to the end of your batch script: :EmailSub SetLocal ENABLEDELAYEDEXPANSION mailsend.exe -log temp.txt timeout 5 Findstr /I /M /C:"Mail sent successfully" Temp.txt >nul If Not !ErrorLevel! == 0 ( Del Temp.txt GoTo EmailSub ) Else ( Del Temp.txt ) Del "%~3" EndLocal Exit /B When you need to send an email in your batch script, use this command: Call :EmailSub If you have variables in your script that are used when sending the email, you would use: Call :EmailSub %var1% %var2% %var3% You then use those variables by writing: %1 %2 %3 ...within the subroutine.
I think it only retires once. Please help me understand your code If I have mistakenly taken it as one single attempt of retry.
What I would suggest is to have an Maximum number of attempts; Example 5. While looping till the maximum attempts is met, in each attempt it should retry rather than measuring solely on timeout.
This loops continuously until "Mail sent successfully".
:Email c:\mailcfg\mailsend.exe -to %1 -from "xxxxxxxxxxxxxxx" -starttls -port 587 -smtp smtp.gmail.com -sub %3 -M "Please open attached from xxxxxxxxxx" -ct 15 -read-timeout 15 +cc -q -auth -user "xxxxxxxxxxxxxxxxxx" -pass "xxxxxxxxx" -attach "%4.pdf" -log temp.txt
:EmailSub SetLocal ENABLEDELAYEDEXPANSION timeout 2 Findstr /I /M /C:"Mail sent successfully" temp.txt >nul If Not !ErrorLevel! == 0 ( Del Temp.txt GoTo Email ) Else ( Del Temp.txt ) EndLocal Exit /B
From derauvil...@gmail.com on December 23, 2013 12:31:27
I would like to request at least a switch that tells Mailsend to re-attempt sending an email if there is a connection error.
I have to email some large attachments once a week and it takes 10-15 minutes to send each email at my connection speed. My solution has been to use this program and Windows Task Scheduler to schedule the emails to be sent during the night.
Unfortunately, I have found that my internet would sometimes disconnect for a minute or two while the scheduled task is running. When this happens, due to the way I have things set up, the email currently being sent as well as every other one in the queue doesn't get sent.
The solution to this would be if Mailsend could be told to try send the email again if there is a connection problem rather than aborting. You could also add two new switches as well, one to specify how many times the email should be resent and the second to specify how long the program should wait before attempting to send the email again.
If you could code this so that a for -> do loop with Mailsend in it isn't interrupted, that would be even better.
Original issue: http://code.google.com/p/mailsend/issues/detail?id=41