-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting the email entered in the form as from email for notification #146
Comments
Hi @mikaelekstrom, Not out of the box. If you're into C#, you can hook into the |
Cant really find where in the code the from address is set and the email is actually sent. |
@mikaelekstrom try something like this (disclaimer: I haven't tested it): using System.Linq;
using System.Net.Mail;
using FormEditor;
using FormEditor.Events;
using FormEditor.Fields;
using Umbraco.Core;
namespace MySite
{
public class ApplicationEvents : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
FormModel.BeforeSendMail += FormModelOnBeforeSendMail;
}
private void FormModelOnBeforeSendMail(FormModel sender, FormEditorMailCancelEventArgs formEditorMailCancelEventArgs)
{
// find the first email field and grab the submitted email address
var from = sender
.AllFields()
.OfType<EmailField>()
.FirstOrDefault(f => f.HasSubmittedValue)
?.SubmittedValue;
if(string.IsNullOrWhiteSpace(from))
{
// no submitted email address
return;
}
// set the from address on the email
formEditorMailCancelEventArgs.MailMessage.From = new MailAddress(from);
}
}
} |
Closing this due to lack of activity. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it possible to set an email address entered in the form as the from email for the notification email?
So you can then respond directly to the the person submitting the forms email whitout having to log in to umbraco och create a new email?
KR,
Mikael
The text was updated successfully, but these errors were encountered: