Expand my Community achievements bar.

Pull email address from text field

Avatar

Level 4

Hello,

I have form in which I have a submit button set to email several people with Mailto: <a couple of different addresses>. Those addresses don't change.  I would also like to include an email from a text field.  This will change from submission to submission.  Is there a way to get that address automatically added in to email when the submit button is clicked?

Thanks!

3 Replies

Avatar

Level 5
//fill in e-mail
var Mailto = Formular1.s1.email.rawValue;
//var Mailto = "test@test.de";

//fill in subject
var SubjectBetreff = Formular1.s1.betreff.rawValue;
//var Betreff = "Test-Betreff";

//fill in message
var MessageNachricht = "Content PDF:\r" + "Field content: " + Formular1.s1.inhalt.rawValue + "\rName: "
+ Formular1.s1.name.rawValue + "\rDatum: " + Formular1.s1.datum.formattedValue;
//var Nachricht = "This is a test message.\r2.row start here.\r3.row here.";

//fill in e-mail cc
var CC = Formular1.s1.emailcc.rawValue;
//var CC = "testcc@test.de";

//fill in e-mail bcc
var BCC = Formular1.s1.emailbcc.rawValue;
//var BCC = "testbcc@test.de";

var Mail = "mailto:" + Mailto + "?Subject=" +
SubjectBetreff + "&Body=" + MessageNachricht + "&cc=" + CC + "&bcc=" + BCC;

//cSubmitAs: "PDF" send the pdf as attachment
//cSubmitAs: "XML" send the pdf as xml-attachment
event.target.submitForm({
cURL: Mail,
bEmpty: true,
cSubmitAs: "XML"
});

You could use the script above in your button. But you have to use a normal button and rename as submitbutton. You can't use the normal button for this.

Hope it will be helpful?

Mandy

Avatar

Former Community Member

Hi Nele

I am new to Live cycle and java. I am trying to implement the code into my form and having some difficulties. Is Formular1 my email field. Field where I enter an email address?

thank you

Avatar

Level 4

I'm still somewhat novice myself with Java scripting.  I'm not sure which event I should put this on for the button.  It would seem like Click would be a logical choice, but that's not available.  Also, I'm unclear on how the email address that can be changed is being picked up versus the set email addresses are there.  I don't know what the difference is between your red text and your black text.

What I'm looking to do is have johndoe1@test.com and janedoe2@test.com always get the email and also have the email address field on the form somehow linked to the button so that whatever address is in there gets the message as well.  I don't need cc and bcc.  If I can do something with a subject line great.  I don't need to have anything in the message. 

Finally, I'm assuming that I don't really need to have SubjectBetreff but rather just Subject.  I'm a little confused by the German in the scripting.  I just script in English.

Thanks!