Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Email script

Avatar

Former Community Member

Just a simple javascript to send a form via email,thats all I need ,lol

9 Replies

Avatar

Level 5

You could use the following. You could use field entries, then you have to change the path and the objectname to yours.

var Mailto = Formular1.s1.email.rawValue;


You could use static text

var Mailto = "test@test.de";


It's your choice.


//fill in e-mail

var Mailto = Formular1.s1.email.rawValue;

//var Mailto = "test@test.de";

//fill in subject

var Betreff = Formular1.s1.betreff.rawValue;

//var Betreff = "Test-Betreff";

//fill in message

var Nachricht = "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=" + Betreff + "&Body=" + Nachricht + "&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"

});


I hope that will helps?

Mandy

Avatar

Level 5

You could also use the following:

  1. Take a submit-button.
  2. Fill in the emailadress.
  3. Fill in the subject.
  4. Select "submit as" XML or PDF.

submit.jpg

I hope one of the both will helpful?

Kind regards Mandy

Avatar

Former Community Member

Thank you for this.

What does Nachricht and betreff mean?Also,how do I add a field from the form to the subject line?

Thanks!!!

Avatar

Level 5

Sorry. I come from Germany. This is the german word for message.

Nachricht = Message

Betreff = Subject

I forgot to change this.

But this is only a variable..

You can work with them?

Avatar

Former Community Member

Hi and thank you.

Is there a way to display a message right after the submit button is clicked and before the email client opens?

Thanks!!!!

Avatar

Level 5

For which reason?

You want check if the message is correct?

Avatar

Former Community Member

A simple message like thank you for submitting the form.

Avatar

Level 5

You can solve this about the

xfa.host.messabeBox(Nachricht, "Information for user.", 1, 0);

Avatar

Level 1

Hi, this is great info for me as I've been trying to manage a BUTTON to send out an email strictly as a PDF file.  The attached form needs to be in the name the form was initially saved.  I'm using your example below but it is sending the PDF form as an XML file.  My problem is I'm not sure what type of "Control Type" button under the "Field" object I should use and I want to make sure that form sent is 1) In the name of the form being sent, and 2) is being sent as a PDF file.  Thanks for your help...

  1. //cSubmitAs: "PDF" send the pdf as attachment 
  2. //cSubmitAs: "XML" send the pdf as xml-attachment 
  3. event.target.submitForm({ 
  4. cURL: Mail, 
  5. bEmpty: true, 
  6. cSubmitAs: "XML" 
  7. });