Get emails from CMS in xslt file when sending to different emails
Hi all,
Currently, I have an xslt file which is being used when form is submitted.
I am getting the value from a particular dropdownlist and send the form to different emails (hardcoded) based on the selection that the user choose from the dropdownlist. I have followed the following discussion -
But now, I would like to get the email from the umbraco CMS or from anywhere where client does not want to edit the xslt file, to be more user friendly.
An approach to this could be to create a "Form settings" tab on your homepage node for instance so the client can enter the e-mail values there.
Then you can use XSLT to fetch the data from there instead so nothing needs to be hardcoded.
You could write $currentPage/ancestor-or-self::*[@isDoc and @level = '1']/senderEmailAlias to get the value for the sender e-mail address and store it in a variable...so for instance your code could look like this
<xsl:variable name="senderEmail" select="$currentPage/ancestor-or-self::*[@isDoc and @level ='1']/senderEmailAlias" />
<xsl:variable name="receiverEmail" select="$currentPage/ancestor-or-self::*[@isDoc and @level ='1']/receiverEmailAlias" />
<xsl:value-of select="umbraco.library:SendMail($senderEmail,$receiverEmail,'Enquiry',$bodyText)" />
Something like that should do the trick - The "senderEmailAlias" and "receiverEmailAlias" should of course be the name of those property aliases that you define yourself. And you can of course also make it possible for the client to define the "Enquiry" field as well.
What is the scope of the send email in the SendEmail method of Umbraco, since there is already the SMTP settings (username and password) already set in the Web.Config?
My point was, why you need to set the sender Email if you have already set the username and password of the email server that you use to send emails in Umbraco?
My guess is because that you are using the Send xslt transformed email workflow that does not read the value from the web config file or UmbracoSettings config file.
Well, it's just the way the method works, which I think is fine since you don't necessarily want to always send e-mails from the same account.
the username in the smtp settings in web.config is standard .NET and I guess it could be used by an extension if it read that value but first and foremost it's just used as the credentials needed in order for you application to be allowed to send out emails using a certain SMTP protocol.
Usually Contour uses the e-mail address specified in the /config/UmbracoSettings.config file unless something else is specified.
But anyhow...if the client needs to be able to edit the email addresses they will need to be able to do so using the Umbraco backoffice.
Besides, I currently, if you choose to send forms based on user selection, it always send to a particular email address that you specify in the contour worklow.
How can I disable the option not to send submitted forms to the that receiver email, since we are choosing to send email in the .xslt file?
Hmm, good question - Now I'm a bit uncertain about the direction we have taken here.
What is your reason for wanting to overrule the default e-mail workflow? Why is it that it's not good enough to use those existing fields?
I just need to understand it so I'm sure that the approach we're taking on this one makes sense.
You can probably digg into the source somewhere and stop the e-mail from being sent but I don't think that's a good approach though. If it's not possible to just leave the field empty a nasty workaround can be to just setup an e-mail address that does not exists...yeah, that's not pretty.
In a way it does not make sense anymore if you are choosing to which email address are you sending the form submission based on a dropdown value that the user will select.
So, basically, I have a dropdown list where user wants to select the subject of the enquiry form. So t have decided to create an xslt file where I choose the received email address to send based on which subject the user selects.
So if user selects subject 1, form will be submitted to [email protected], for example.
If user selects subject 2, form will be submitted to [email protected].
So my point is that the default recevied email of the umbraco contour is no more necessary since I am choosing the recevier email accoridngly the subject selected.
Apart from set an non-exist email and avoid received Notification Failtur notification :), are there any solution how to disable this option?
Get emails from CMS in xslt file when sending to different emails
Hi all,
Currently, I have an xslt file which is being used when form is submitted.
I am getting the value from a particular dropdownlist and send the form to different emails (hardcoded) based on the selection that the user choose from the dropdownlist. I have followed the following discussion -
http://our.umbraco.org/forum/umbraco-pro/contour/15723-Sending-email-to-certain-email-address-dependent-on-selection-in-form
But at the moment, the email values are inputted hard coded in the xslt file for the email template, like so:
But now, I would like to get the email from the umbraco CMS or from anywhere where client does not want to edit the xslt file, to be more user friendly.
Appreciate any help from someone!
Thank you.
Regards
Hi Simon
An approach to this could be to create a "Form settings" tab on your homepage node for instance so the client can enter the e-mail values there.
Then you can use XSLT to fetch the data from there instead so nothing needs to be hardcoded.
You could write $currentPage/ancestor-or-self::*[@isDoc and @level = '1']/senderEmailAlias to get the value for the sender e-mail address and store it in a variable...so for instance your code could look like this
Something like that should do the trick - The "senderEmailAlias" and "receiverEmailAlias" should of course be the name of those property aliases that you define yourself. And you can of course also make it possible for the client to define the "Enquiry" field as well.
Hope this helps!
/Jan
Thank you Jan for your response.
I will give it a try.
Cheers.
Hi Simon
Good - Let me know if it works out for you :)
/Jan
Hi Jan,
What is the scope of the send email in the SendEmail method of Umbraco, since there is already the SMTP settings (username and password) already set in the Web.Config?
Thank you in advance.
Regards.
Hi Simon,
Try to see this documentation about additional steps for proxy and email setup http://our.umbraco.org/wiki/install-and-setup/how-to-install-umbraco-on-windows-server-2008/additional-steps-for-proxy-email-setup
Hope this answers your question about the SMTP settings.
/Dennis
Hi Dennis,
My point was, why you need to set the sender Email if you have already set the username and password of the email server that you use to send emails in Umbraco?
thanks
Regards
Hi Simon,
My guess is because that you are using the Send xslt transformed email workflow that does not read the value from the web config file or UmbracoSettings config file.
But just my guess. If you see the library method for SendMail, it takes these five parameters. http://our.umbraco.org/wiki/reference/umbracolibrary/sendmail
/Dennis
Hi Simon
Well, it's just the way the method works, which I think is fine since you don't necessarily want to always send e-mails from the same account.
the username in the smtp settings in web.config is standard .NET and I guess it could be used by an extension if it read that value but first and foremost it's just used as the credentials needed in order for you application to be allowed to send out emails using a certain SMTP protocol.
Usually Contour uses the e-mail address specified in the /config/UmbracoSettings.config file unless something else is specified.
But anyhow...if the client needs to be able to edit the email addresses they will need to be able to do so using the Umbraco backoffice.
Hope this answers your question :)
/Jan
Hi all,
thank you for your response.
Besides, I currently, if you choose to send forms based on user selection, it always send to a particular email address that you specify in the contour worklow.
How can I disable the option not to send submitted forms to the that receiver email, since we are choosing to send email in the .xslt file?
Thank you in advance.
Kind regards
Hi Simon
Hmm, good question - Now I'm a bit uncertain about the direction we have taken here.
What is your reason for wanting to overrule the default e-mail workflow? Why is it that it's not good enough to use those existing fields?
I just need to understand it so I'm sure that the approach we're taking on this one makes sense.
You can probably digg into the source somewhere and stop the e-mail from being sent but I don't think that's a good approach though. If it's not possible to just leave the field empty a nasty workaround can be to just setup an e-mail address that does not exists...yeah, that's not pretty.
/Jan
Hi Jan,
In a way it does not make sense anymore if you are choosing to which email address are you sending the form submission based on a dropdown value that the user will select.
So, basically, I have a dropdown list where user wants to select the subject of the enquiry form. So t have decided to create an xslt file where I choose the received email address to send based on which subject the user selects.
So if user selects subject 1, form will be submitted to [email protected], for example.
If user selects subject 2, form will be submitted to [email protected].
Any other subject will be redirected to [email protected]
So my point is that the default recevied email of the umbraco contour is no more necessary since I am choosing the recevier email accoridngly the subject selected.
Apart from set an non-exist email and avoid received Notification Failtur notification :), are there any solution how to disable this option?
Thank you in advance
Kind Regards
simon
HI Simon,
Have you seen this documentation on how to extending contour, sending email dependent on form selection. In this example they show it with radio button list, so I think you get a good starting point here. http://our.umbraco.org/wiki/how-tos/extending-contour,-sending-email-dependent-on-form-selection
Hope this helps,
/Dennis
Hi Dennis,
it's quite a complicated solutions comapred to the xslt file solution.
The only discrepancy and dilemma is how to tell umbraco contour not to send the default email since we are dealing with them in the xslt file.
But thanks anyway for your help.
any idea pls
Regards
Hi Simon,
Did you ever work out a solution to this? I have the same issue and would like to stop the default email being sent.
is working on a reply...