Developer forum

Forum » Development » Send emails using Forms for Editors and API

Send emails using Forms for Editors and API

Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi,

 

Sometimes we need to submit emails in custom development, but still have some configuration. I was wondering if I could (using the API):

  • Point to a DW page where there's a Forms for Editors paragraph
  • Submit some parameters, so that the module would auto-fill the fields
  • Trigger the submit button

 

That way we could easilly develop and changes the email templates and add fields. Unless somebody knows of a better/simpler way to do this, other than doing it hardcoded, or looking into GlobalSettings or a config file (which makes it harder for customer to make updates).

 

Best Regards,

Nuno Aguiar


Replies

 
Nicolai Pedersen
Reply

Hi Nuno

That part of the module is not build for that. You can create a new instance of Dynamicweb.Forms.Frontend and call InitializeModule.

Then you can call GetContent() that will render the form for you. But autosubmitting - I do not know how to do. You could do a redirect and put everything in the querystring...

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

Gotcha. I will try the redirect with querystring parameters. I'll just have to see how the anti-spam feature would handle it. That would probably be good enough to create these notifications.

 

Thanks,

Nuno Aguiar

 
Nicolai Pedersen
Reply

Ah - antispam. Good point - that will NOT work since it requires a user to click a button and get some js executed...

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Right, then maybe this could be a feature request, in other words if I could (through the API):

  • Get a paragraph instance where Forms for Editors exist using GetPageIdByNavigationTag
    AND
  • Assign a dictionary<key, value> or class with the parameters
  • Trigger the submit - which through the API would override the anti-spam validation

 

My thinking was that I could use that to trigger emails, where the "After submit" template would be the confirmation, and if there were errors the forms "template" would provide that.

These pages could be just like the other AJAX feeds like the ones you could find in Rapido.

 

Maybe it's farfetched, but I see a benefit where custom development would be more easilly documented and we would not need to create settings in GlobalSettings nor config files nor UI panels, making developments also faster and more maintainable.

 

Nuno Aguiar

 
Nicolai Pedersen
Reply

No.

You can create an item type with the fields you need, add a page somewhere in the tree, and user the mailing API to do the job. Why use the forms module to send mail when you do not have a form. Wrong tool to the job!

BR Nicolai

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

Godd point. I hadn't thought of that. I will take that route instead.

 

Thanks for the brainstorm.

 

Nuno

 

You must be logged in to post in the forum