Closed mikaelekstrom closed 7 years ago
Hi @mikaelekstrom,
Not out of the box. If you're into C#, you can hook into the BeforeSendMail
event - see this section of the docs.
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.
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