Sometimes it is useful or necessary to send a web link via email. The receiver can simply click on the link or copy and paste it into their browser's address bar to load the corresponding web page.

The following example will demonstrate how to send email from a batch file incorporating web page link.

SOLUTION:

The batch file takes on two parameters. These parameters are the recipient and an additional message. Batch file parameters are referenced as %1, %2, %3, ., %9. Batch file given in example can be called either by another batch file which would provide values for %1 and %2 variables or manually from command line.

The comments in the batch file explain what happens when certain batch commands are executed.

@Echo off
:: Batch file - SendLink.bat

:: Turn off the displaying of individual batch file lines
:: This command tells the batch file to only display output

:: If there are no 2 parameters, then display error message

IF [%1] == [] GOTO no_params
IF [%2] == [] GOTO no_params

:: Execute the command
febootimail -SERVER mail.server.com -FROM myemail@address.com -TO %1 -SUBJECT "Requested web page link" -MSG "Use following link or copy and paste it into the address bar of your web browser: <BR>" -MSG ^<a href="%2"^>%2^</a^> -HTML -QUIT

:: Exit batch file, instead of displaying error message
GOTO :eof

:: Display error message if all parameters are not entered
:no_params
ECHO Not enough parameters. Format example:
ECHO SendLink.bat "TO" "WEB LINK"
ECHO SendLink.bat "john@recipient.com" "www.febooti.com"

1: The -SERVER parameter is used to define the name of the outgoing mail server. This can be in the form of a standard URL or as an IP address. The server can be defined in the batch file as it is likely that for most outgoing email the server will be the same. The value can also be entered from the command line. All that is needed is for the value for the -SERVER parameter to be replaced by a batch file variable.

2: The -FROM parameter is used to specify who the sender of the email is.

3: The -TO parameter accepts the first parameter of the batch file as the recipient of the email. This can either be entered as a single email address or multiple email addresses separated with commas. Friendly names can also be used provided they are enclosed in double quotes, e.g. ""John Doe" <john@recipients.com>".
The %1 tells the batch file that it should be replaced by the first parameter that is entered as part of the batch file. Use of these variables enables batch files to accept parameters.

4: The -SUBJECT parameter gives a simple description of what is contained in the email.

5: The first -MSG parameter allows the email to be customized with a friendly message. Multiple combinations of this parameter can be used to send html or plain text mail.

6: The second -MSG parameter takes its value from the second batch file parameter. This parameter contains html commands that need to be entered in the batch file in a certain way. It is important to use an escape character ^ before certain characters such as "<" and ">" to print or use them in batch files, otherwise they will be interpreted as batch commands.

7: The -HTML parameter specifies that some html formatting and tags are used within the message. Febooti DOS email utility will then attempt to send the message in html format.

8: Finally the -QUIT parameter indicates to Febooti DOS email tool not to display any output.

Please do not hesitate to contact our support department with any possible further questions or to solve practical issues connected with Command line email integration.

Copyright © 2001-2010 Febooti Software. All rights reserved. Last Updated: November 03, 2008