Adding Action To Send Email

rcatalino1763
rcatalino1763 Community Member Posts: 10 ☆ Roadie ☆
I have a project that requires a notification go to an individual based on which option is chosen on a test question.  There is an action that allows me to say "On Select/Change" - "Send Email" and then there is a box to enter the email address in.  Is there a way to put a subject line on the email?  And, what is the best way to identify who sent it?  (i.e. will CourseMill include that automatically somehow or do I need to have them enter their name in a survey question or something?

Comments

  • jasonadal
    jasonadal Community Member Posts: 450 ♪ Opening Act ♪
    Hi Rhonda,

    I do this with a feedback option in one of my courses so that it sends to multiple individuals and has a default subject line. I use a RunJS on a button on the final page of the course with the following:
    window.location.href = "mailto:<your email address>?subject=<subject for email>&cc=<person to CC>";
    If you use the JS above and copy/paste, you will need to update the quotation marks. You could even add initial body for the email using "&body=<some body text>" or a bcc "&bcc=<email address>"

    The ? indicates the first parameter to add to the email and the & attaches each additional parameter.

    Hope this helps!
  • rcatalino1763
    rcatalino1763 Community Member Posts: 10 ☆ Roadie ☆
    Hi Jason!  Thanks for quick feedback.

    I'm assuming you put the JS directly in the empty white box?  I have a full string of it written already that I had used in a separate situation and I hadn't thought of actually putting it directly into Lectora.  I'll try that see what happens.  Thanks so much!

     

     
  • jasonadal
    jasonadal Community Member Posts: 450 ♪ Opening Act ♪
    That's correct - you can copy and paste the text in my post into the RunJS box and replace the "<your email>" etc. without the brackets. Just make sure to re-do the quotation marks, though - if you leave them as is, it doesn't work.

    If you want, I can post a page with a sample a little later so you can see how it all fits together and behaves.
  • rcatalino1763
    rcatalino1763 Community Member Posts: 10 ☆ Roadie ☆
    A sample of that would be tremendously helpful.  I don't want to impose but if you have time, I'd greatly appreciate it.  Thanks you!
  • jasonadal
    jasonadal Community Member Posts: 450 ♪ Opening Act ♪
    Not a problem! It was really just a matter of copy/pasting into a new title and removing some elements that would have borked up the page. Keep in mind that this should open the user's default email client and may throw out a warning. The warning is asking if the user wants the web page to allow access to the program. There's no way around this and is entirely dependent on the user's browser settings. You may want to consider adding that information to the page just in case.

    (You get a bonus function on this page of an animated character changing poses that is not part of the default character set in Lectora.)
  • klaatu
    klaatu Community Member Posts: 986 ☆ Roadie ☆
    If you need to build in this functionality without engaging the clients email application you can use PHP. PHPMailer is an awesome free script.
  • rcatalino1763
    rcatalino1763 Community Member Posts: 10 ☆ Roadie ☆
    Jason, the example worked like a charm!  I was able to put the body text that I wanted and everything.  Thank you so much for sharing that and saving me hours of trying to figure it out.  I feel accomplished for today :)  BTW, your looping character was a cool bonus that I'll find a place for.

    Darrel, thanks for your input. I'm not very familiar with PHP code and it appears that I've got this situation fixed for now but I'll keep this in mind and reach back out to you if something comes up that I want to dive into that.  You guys are all lifesavers!