Send Email Action

clammers
clammers Community Member Posts: 122 ♪ Opening Act ♪
Can anyone assist me in replacing the Mail To action previously in Lectora? I have previously used this action in a few instances throughout several courses and now have to go back and update all of these. Scanning for forums, I found a post on creating the following javascript:
var email = “[email protected]”;
var subject = “My Notes”;
var body = Var_NoteSummary.getValue();

window.location.href = “mailto:” + email + “?subject=” + subject +”&body=” +body
 

However, when I implement this, all I get is a white screen when I Run/Preview/Preview in Browser. Further, I need the ability to create several mailto actions: as there are multiple e-mail addresses throughout the course.

 

Any help is appreciated.
«1

Comments

  • carlfink
    carlfink Community Member Posts: 947 ♦ Idol ♦
    To clarify for my benefit: do you want to mail the contents of the Lectora page somewhere, or open a new message in the student's own mail program (e. g. Outlook)?
  • klaatu
    klaatu Community Member Posts: 988
    Hi, Clammers. It looks like you found an old post of mine. Here it is working in version 18. If you have any problems or need something different let us know.
  • bobdinkins
    bobdinkins Community Member Posts: 33
    All I want is what I used to have.  Click and link and an email client opens with the email address in the "to" line.  I've tried the javascript and it doesn't work.  Any ideas before I dump Lectora all together and use something else?
  • klaatu
    klaatu Community Member Posts: 988
    If you tried what I posted and it didn't work you are most likely doing something incorrect. I understand your frustration; I do most of my work from scratch without a delivery authoring tool as it gives me much more freedom to do whatever I want without bloated wonky code but this one is easily rectified.

    This line window.location.href = 'mailto:[email protected]' will do exactly what you said you want to happen. If you copy and paste this into a run javascript action it will open the users email client with [email protected] already in the To: address. Nothing else.

    You are publishing to check, correct, not just using the built in preview? Also, the machine you are working on has an email client set up, right?

    Let me know how it works.
  • clammers
    clammers Community Member Posts: 122 ♪ Opening Act ♪
    I agree with Bob -  I just need something simple that will create a new email message (in the user's email client) with the address in the 'TO' field. In my situation, if I want to provide a list of e-mail addresses within the body text of a page, all I need is a hyperlink to 'MailTo' the given address. For example, "Please contact [email protected] for questions regarding this section of the training."

    Darrel, the solution you  provided works properly and is good for filling out a form; I have used something similar for other applications. However, it's more involved that what is needed (and what was offered previously in Lectora).
  • cmoschella3010
    cmoschella3010 Community Member Posts: 2
    Hi All,  My solution was to go back to my Lectora Version 17 and then copy and paste into Lectora Version 18 any icons that had the send email action attached . This approach seems to work for me. I agree with  Clammers  a simpler solution within Lectora Version 18 would be better.

    Cheers all!
  • klaatu
    klaatu Community Member Posts: 988
    As Carmelo suggested (good suggestion by the way) here is a button library object from v17 with email action attached. Add to your library objects.

    It is, however, advantageous to learn and use a little bit of JavaScript but I understand this is easier.
  • clammers
    clammers Community Member Posts: 122 ♪ Opening Act ♪
    Thanks, all. I've been copying-and-pasting the action from prior courses, so this is much easier. However, it doesn't solve the issue with in in-text hyperlinks. I can use this as a workaround, but <span style="text-decoration: underline;">please</span> Lectora, bring back this action.
  • klaatu
    klaatu Community Member Posts: 988
    Here's the email action on a block of text that is styled to look like an email link (underline and different color). Just add to your library then when you add it to your page change the text to match the address you put in the action.
  • bobdinkins
    bobdinkins Community Member Posts: 33
    I appreciate your help, but it's not working for me.

    Using the "Send Email.awt" you sent I created a button on the page where you have the message box.  I gave it the action OnMouseClick > Run JavaScript > window.location.href = ‘mailto:[email protected]'.  Then published.  The only thing that appears is a blank page.  It doesn't matter which browser I view it in.  I'm viewing locally, not served.
  • klaatu
    klaatu Community Member Posts: 988
    Bob, do you have a mail client, like outlook, on that computer? If there is a mail client it should open up a new email with your address loaded in. Doesn't matter if it is on a server.

    You can also try to import the email button object from my other post and then just drag it into a page and change the address in the action. To import the awo, you first save it (desktop works fine) and then open up your "my library" tab in Lectora. Double click the library objects folder and then add file. Browse to where you saved the awo and select it. Now you can drag it into any project and just change the address.

     
  • bobdinkins
    bobdinkins Community Member Posts: 33
    I have Outlook and it's open.  I just published the "email button.awt" file as you sent it.  The button shows but it nothing happens.  That's the issue I found in the first place.  The Send Email action shows since it was put in with an older version of Lectora, but Trivantis took out the code behind it, so it doesn't work any longer.  It's very frustrating that they would do that.
  • klaatu
    klaatu Community Member Posts: 988
    There is something wrong with your computer. Both of the solutions I posted work fine. It appears your computer is not defaulting email to a client application. Does any email link in another application open up your outlook?
  • bobdinkins
    bobdinkins Community Member Posts: 33
    I think you are exactly right.  I found a website that had an email link (hard to find, by the way) and it didn't work.  Thanks for helping me with this.

    Now, on to research this computer issue!
  • bobdinkins
    bobdinkins Community Member Posts: 33
    Thanks again for the suggestion.  The MAILTO default was set to Chrome instead of Outlook.  It works now.  You are a genius!

    Bob
  • klaatu
    klaatu Community Member Posts: 988
    I'm glad you got it working.
  • clammers
    clammers Community Member Posts: 122 ♪ Opening Act ♪
    I attempted to incorporate the library object, but when I change the recipient, reverts back to [email protected]
  • klaatu
    klaatu Community Member Posts: 988
    Clammers you are correct. I apologize. I did not test it beyond the first email. Here are two similar library objects that have the run JavaScript built in. Its pretty much the same as the other two I posted but will work properly. You'll just need to change the address just as you would have with the first ones.
  • wheels
    wheels Florida USACommunity Member, Administrator, Moderator, Rockstar Manager Posts: 574 eLearning ROCKSTAR Admin Team
    Here is a title as a Lectora Online package file (which you can import to any Lectora) which has a JavaScript action to send email. It allows you to modify variables for the send to email, subject, cc, bcc, and body.

    Should work great, please let me know if there is an issue with it.
  • Chris Paxton
    Chris Paxton Community Member Posts: 104 ☆ Superstar ☆
    If we wanted to have the JS automatically put the subject into the email...could we?

    This is how I used to do [email protected]?SUBJECT=CourseCode or Course Name

    I currently have my button with an action to Run JS and in the window, I've put: window.location.href = "mailto:[email protected]";

    The above works fine in ScormCloud, but if I try any variation to add the subject, I only see a white screen in ScormCloud.

    Here are the variations I've tried: I have my JS (I took a 1-day class in October) notes at home and I'm traveling, but have someone asking me about it now. Any help would be appreciated!!!

    -Chris
    Chris Paxton McMillin, D3 Training Solutions
    [email protected]
    www.d3trainingsolutions.com
  • tgleason9221
    tgleason9221 Community Member Posts: 8
    Hi,

    Question mark only after the email address and move the quotes to the end, like this:

    window.location.href = “mailto:[email protected]?SUBJECT=CourseCode"

     
  • Chris Paxton
    Chris Paxton Community Member Posts: 104 ☆ Superstar ☆
    Hi Tim-

    Thank you for your response, but I still think I'm missing something...I put the OnMouseClick Action of "Run JavaScript" and in the Target put “mailto:[email protected]?SUBJECT=CourseCode"

    When I try to test it in ScormCloud, the page doesn't even show, I just see a white screen. If I remove the "SUBJECT=CourseCode" section, I can see it.

    I've attached the page in case that might help.

    Thoughts?

    -Chris
    Chris Paxton McMillin, D3 Training Solutions
    [email protected]
    www.d3trainingsolutions.com
  • klaatu
    klaatu Community Member Posts: 988
    Try SUBJECT in lowercase.
  • Chris Paxton
    Chris Paxton Community Member Posts: 104 ☆ Superstar ☆
    It still shows up a page of white. :(
    Chris Paxton McMillin, D3 Training Solutions
    [email protected]
    www.d3trainingsolutions.com
  • tgleason9221
    tgleason9221 Community Member Posts: 8
    The first quotation mark appears to be a smart quote.  This can be easily noticed if you copy/paste into notepad or a similar text editor.  If you have code that is inexplicably not working it's always a good idea to try this to identify an abnormality.  See attached.  Replace the first quotation mark with a standard one and you should be good.