Upon finishing email sending procedure utility Command line email client returns errorlevel value (return / exit code) which indicates whether email was sent without any errors or there was a warning (partial data incompability) or even failure to deliver the message to SMTP server.
Errorlevel values returned by Command line email client, can be used in conditional processing in batch programs.
if [not] errorlevel number command [else expression]if errorlevel number commandif errorlevel number command else expressionif not errorlevel number commandif not errorlevel number command else expression
See below on how to use errorlevels for either getting more control over email sending process in batch files or ensuring a successful task completion.
Example of simple batch file script:
@echo off
:begin
febootimail -FROM john@senders.com -TO bat@receive.com -MSG "This message is sent by Windows Command line email client."
if not errorlevel 5 goto end
echo Couldn't connect to server. Trying again...
goto begin
:end
echo End of batch program. Full list of errorlevels (return / exit codes) returned by Febooti Command line email client utility:
| Errorlevel | Errorlevel / return code description |
| No error. |
| Error opening file. |
| Error reading file. |
| Couldn't send message: server response (additional error information may be shown). |
| Couldn't connect to server (additional detailed error information may be shown). |
| Fields TO (or CC / BCC) and FROM are required. |
| Failed to initialize the Windows Sockets. |
| MFC initialization failed. |
| Invalid port number. Valid ports: 0-65535. |
| File: "file specified" too big to fit in memory. |
| Failed to prepare email for sending. |
| Couldn't save EML file to disk. |
| TO required when using SPLIT / TOEACH parameter. |
A warning code is returned only if there is no errorlevels (1-10, 16-18). The email can be sent with some warnings.
| Warning | Warning description |
| Warning: Unknown parameter. |
| Warning: Bad IMG tag, image skipped. |
| Warning: Can't open image file: "file specified". |
| Warning: Maximum pictures count of n reached. |
| Warning: Can't open file: "file specified". |
| Warning: Missing parameter after "specified" command. |
Other messages (additional error information) without errorlevel:
| No errorlevel | Message description |
| - | There was an error accessing registry. Administrator rights might be necessary. |
| - | Warning: Failed to connect to e-update server. |
| - | Warning: Can't open log file. |
| - | Warning: Can't write log file. |
| - | There was error(s) while sending message. |
| - | e-mail(s) sent with some warnings. |
| - | SPLIT / TOEACH ignored when saving EML file. |
Previous Febooti Command line email versions (v1.3 and below) may have different errorlevel and warning messages, because of errorlevels and error messages have been modified slightly in Command line email v2.0.
Example of more advanced batch file script: errorlevel values used as defined variables.
@echo off
febootimail -FROM john@senders.com -TO bat@receive.com -MSG "This is second message sent by Utility Command line email"
:: Perform conditional processing...
if %errorlevel% GTR 2 goto other
goto label%errorlevel%
:label0
echo Program had return code 0... No error.
goto end
:label1
echo Program had return code 1... Error opening file.
goto end
:label2
echo Program had return code 2... Error reading file.
goto end
:other
echo Program had return code value larger than 2.
:end
echo End of batch file script. - Febooti Command line email utility parameters.
- Please don't use this tool to send Unsolicited Commercial Email (SPAM).
- Perform conditional processing in batch programs - microsoft.com website.
Please do not hesitate to contact our support department with any possible further questions or to solve practical issues connected with Command line email.