Form Actions‎ > ‎

Email

Send Email

This action does exactly what it says. It sends an email using the SMTP server that is defined in DNN Host Settings. The following fields can be configured: 
  • From. This is the sender of the email as it will appear to the recipient. Leave empty to use the system default – if a portal context is set, the portal administrator email is used; otherwise, the email defined in Host Settings is used. This field supports context tokens and My Tokens.
  • To. Determines who will receive the email. Separate multiple email addresses with semicolon. If the Determine Automatically option is used, then Sharp Scheduler tries to infer the email from the Context User. This field supports context tokens and My Tokens.
  • Reply To. When the recipient of the email replies to this email, the To field fills with this email instead of the original From. This only makes sense when sending emails to non-admin users that are likely to reply to those emails. For example, it can be a trial reminder email. Separate multiple email addresses with semicolon. This field supports context tokens and My Tokens.
  • Subject. For best experience, choose something not too short but not too long either. This field supports context tokens and My Tokens.
  • Body. This is the email content. If you need custom data then use other actions, for example the Run SQL action, to fetch it and store it in the job context, then access it through the context tokens. This field also supports My Tokens.
  • Attachments. This action allows you to attach up to 5 email attachments to the email. If a Portal Context is specified, then the file picker will show files that belong to that portal, otherwise, files from the Host folder are listed.


Sending emails step-by-step tutorial


In this tutorial we are going to show you how to set up a simple form (like in the example below) and send an email. There are some subtleties that you have to look after. So let's begin by creating a form with a subject and a message field.

 

 

Creating the form

  1. When the desired page is open in Edit Mode, select the Modules option in the top menu; this will open the Add New Module window. Now select the Add New Module option.
  2. Find avt.ActionForm and with Drag&Drop option add the module to your page. 
  3. Now you have installed Action Form Module on you desired page. Currently the avt.ActionForm is not configured and you will need to do so by selecting Manage Form link. Important: Note that you will need to unlock the 30 Day trial or Activate for Production before you are able to see this screen.
  4. In this example we are going to create a Blank Form. On the Manage Screen, click on the Start button for the Blank Form. You will be redirected to the form settings screen. You can also choose Contact Form, which actually does the same thing.
  5. Just by clicking on the Fields tab, you will be redirected to the screen where you can add new fields.

          In this example we will add the Subject and Message fields.

 

 

     6.  Now we are going to add the form fields. Go ahead and click on the Add Field button and select from the drop down menu the Text > Small Text for the Subject field. 



     7.  Rename the title for this field into Subject and click on the Save button.

 


Repeat the 6 & 7 steps for the Message field with just a small difference; choose the large text option: Text > Large Text.

Setting up the email

For the Submit action, so that the form can be sent to an email, we need a button. From the Add Field drop down menu, select Buttons > Buttonjust like we did with the Subject and Message fieldsRename the button into Send (or whatever you want).

In the end, we will have these 3 fields.


Now lets configure the Send button; we are going to add some Actions for it.

  1. Select the Button field. It will open the settings panel for the Send field. Scroll down to On Click Handler option.
  2. Click on the Add Action button and from the drop-down menu select Email > Send EmailAfter this you will be redirected to the settings panel for theSend Email action.

      3.  In the settings panel for the Send Email action (see the image below) we need to set up some details.

    • In the “To” field put in the email address where the form will be sent.
    • In the “Subject” field put in [Subject] token.
    • In the “Body” field put in the [Message] token.          

After you finish setting up these details, click on the Save button.

      4.  We can also add another action to display a message. This is useful to inform the user that the form was successfully submitted. For this, follow the 2nd step but choose Message > Display Message option. This will open the Display Message settings panel. Put in the Message field your message (ex.: “Your message was successfully submitted.”). When you’re done, click on the Save button. This is it. 


Subscribe to MailChimp

You can set up this action to a button so when the form is submitted it subscribes an email address to a Mailchimp list. The following fields need to be configured so that the form will subscribe the email address to your list:
  • API Key. Login to MailChimp and go to Account > Extra > API Keys. Follow this link to find out more about MailChimp API Key. Action Form requires an API key to successfully connect to a MailChimp account and transfer subscriber information and other data to your list.
  • List Name. The list name has to be exactly as it appears in your MailChimp account.
Click here to read more about the integration with MailChimp.



Form not sending email

Exception:

"Could not send email from ----- "

Cause:

The SMTP is not correctly configured or the SMTP is configured to send emails only from some addresses.

Solution:

Before starting everything, test that the form is working perfectly. Go to Admin > Event Viewer to see if you get any errors.  If the form doesn't work as it should be, you need to verify some settings.

Make sure that the SMTP settings are configured properly. You can find this in Host Settings. Follow this path: Host > Host Settings > Advanced Settings  Test that the Username and Password used to connect to the Server are correct. You can do this by clicking on the Test SMTP Settings button.

Make sure that the email address used to send the form is allowed to send emails. Action Form uses the system default (site email) which is the Administrator’s email. Some servers like Amazon need the email address used to send the form to be verified. Only specific email addresses are allowed to send emails. In Event Viewer, you might get the next error:



So, if in Event Viewer you get the Email address not verified error, you need to set up in the From field the Host email address. The host email could be found under the Host > Host Settings > Basic Settings. Follow this path to set-up the email address: Manage Action Form > Fields > Send (submit button) > Send Email (action) -> Click on the Save button and now your Action Form should work as expected.

It is not difficult to set up Action Form but there are a few aspects and details to look after which are difficult to debug if you don’t know them or if you don't know where to look. In the scenario from above, it was simple because the server told us that he rejected the email and why. In other cases, the server will not tell you the reason, so you will have to figure it out by yourself or sometimes it will not even tell you that it was rejected. It will just show the successfully submitted message but the recipient will not get it, probably the email just remains blocked somewhere in a pick-up folder for example. If the server doesn't do its job, the email will remain in that pick-up folder and no error will get reported.

Once again, if there is an error, Action Form will log it in Admin > Event Viewer.

YouTube Video



Validate email

In order to validate that the first and second email fields have the same value and tell users that the two fields don't match, you can use this scenario:

1. add two Email fields, each one with distinct labels, for example, Email and Confirm Email;

2. on the submit button, on Click Handler section, add two display message actions,

- a first Display Error Message where the conditions should be [Email] != [ConfirmEmail] and a warning message which informs the user that the email addresses do not match;

- a second Display Message with a confirmation text which will be displayed in case both email addresses match.

3. save and test.

Validate if [Email]==[ConfirmEmail] on Submit button

Add 2 fields: Email and Confirm Email.

On the Submit Button, you can add 2 actions. The first action is Display Error Message with the following condition [Email] != [ConfirmEmail] and the second action is Display Message for the case when the email addresses match.


YouTube Video



Send Email to recipient based on multiple choice selection
 

From the Modules drop-down menu select Add Module and choose Action Form. If you choose the blank template, configure the fields to your liking - for example, from the Add Field menu choose Text, then Text Box. Name the first box Subject and the second one Message. Add a third field by choosing Multiple Choice and from there Multiple Choice (with Radio Boxes). This field should be called Recipients. Scroll down to the Items box and fill in the email addresses for each radio box, separated by Enter

laura|laura@example.com

john|john@example.com


where the name before the pipe represents the alias that will be displayed in the Radio Box. If mike| is not entered before the email address, then the email address - and not the alias - will appear in the Radio Box.

Next, add a new field, this time Button. Name it Send, then scroll down and click the Add Action button next to the On Click Handler field. From Add Action choose Email and Send Email, respectively. 

Click on the Send Email handler and in the To field write [Recipients]. These are the email addresses you have previously defined.

Likewise, add another action by using Add Action and choosing Message, then Display Message. Click on Display Message and in the Message field write, for example, Success. This message appears after you have sent the email. In addition, you can also write Success, then separated by enter,  [Recipients]. This way, the email address to which the message has been sent will be displayed. Useful in case you hastily click on a recipient (or more) and you're not sure to whom the mail has been sent.


Add an image/logo to the email sent


In the Send Email action attached to the button, at Format field set HTML, in Body, select Toggle HTML and add expression:

 <img src="url" alt="some_text" width="42" height="42">