15-Oct-03 (Created: 15-Oct-03) | More in 'Howto'

How to send emails on the server side using Aspire

General Introduction

Mailing in Aspire is accomplished using the java mail api. The jar files used for this purpose are activation.jar and mail_1.1.3.jar. Typically sending mail in Aspire is invoked as a result of submitting a form action. In the Asprie parlance this is equivalent to an update url. In aspire an update url is considered a series of actions that take place before redirecting the user to a display url.

Email is programmed as just one of the actions. If you are familiar with the mail api you can write an Aspire Part where you can make use of the java mail api to send your email. This option gives you the greatest flexibility.

An example of using the existing mail part


###################################
# SaveSQLReportURL
# inputs:
# 1. sqlStatement
# 2. report_short_name
# 3. report_long_name
# 4. report_description
# 5. created_by
###################################

request.saveSQLReport.classname=com.ai.db.DBPreTranslateArgsMultiRequestExecutor
request.saveSQLReport.db=reportsDB
request.saveSQLReport.query_type=update

request.saveSQLReport.request.1=SQLReportSeqGenerator
request.saveSQLReport.request.2=SaveSQL
request.saveSQLReport.request.3=ReportSeqGenerator
request.saveSQLReport.request.4=createSQLReport
request.saveSQLReport.request.5=getDefaultFolderId
request.saveSQLReport.request.6=FileReportDefault
request.saveSQLReport.request.7=EN.TranslateForMail
request.saveSQLReport.request.8=EN.CreateBodyText
request.saveSQLReport.request.9=EN.emailNoteAsynchronously


request.saveSQLReport.redirectUrl=/akc/servlet/DisplayServlet?url=ShowFiledReportsJSPURL

###################################
# SendMail
# args: toemail
#            from
#            to
#            subject
#            attachmentFilename
#            bodyText
#            bodyMimeType
###################################

#
#The following will rename parameters so that the 
#mail request executor can use them as its input parameters
#If your input parameters match then you don't have to do this
#
request.EN.translateForMail.classname=com.ai.parts.CopyParametersPart
request.EN.translateForMail.originalNames=profile_user_email,profile_user_email,report_short_name
request.EN.translateForMail.newNames=from,to,subject

#
#You can construct bodyText this way if you have to
#
request.EN.createBodyText.classname=com.ai.parts.SubstitutionPart
request.EN.createBodyText.substitution=\
\n\
\n{report_description}\
\n\
\n\
\n\
{sqlStatement}
request.EN.createBodyText.resultName=bodyText

#
#Call the email executor asynchronously
#
request.EN.emailNoteAsynchronously.className=com.ai.common.AsyncRequestExecutor
request.EN.emailNoteAsynchronously.AsyncRequestName=EN.emailNote

#
#The actual request executor
#
request.EN.emailNote.classname=com.ai.aspire.utils.MailRequestExecutor
request.EN.emailNote.smtpMailHost=smtp.btitelecom.net
request.EN.emailNote.user=(sorry)
request.EN.emailNote.password=(sorry)

References

Read the the source code for com.ai.aspire.utils.MailRequestExecutor for any options that I am missing.

Check the log file for any errors