nopCommerce
nopCommerce copied to clipboard
Add Reply-To for Order Notification Email
nopCommerce version: 4.50
When I receive an order, sometimes I want to reply to the customer directly from the order notification email. Rather than copy and paste the customers email address from the body of the email, it would be easier to click Reply and the customers email address is already in the To field.
Source: https://www.nopcommerce.com/boards/topic/93657/add-reply-to-for-order-notification-email
We could add a new property to MessageTemplate whether to fill in ReplyTo with a customer (or admin) email if applicable.
We already have ReplyTo parameters in SendNotification method, so we should pass them when this new property is set for the particular message template.
Hi! I want to help, but I'm having trouble locating the send email function when an order is processed.
P.S. I'm trying to learn more about the system to be able to contribute more often.
If this task has no assignee. I would love to be assigned to it.
@ChrisClaude Please feel free to make to make a pull request
i have the same problem
@RomanovM do you have find a solution?
I have filled out replyToEmailAddress and replyToName parameter of SendNotificationAsync method for most admin email messages.
@skoshelev any suggestion!
Hi, @parshan2. I looked at your changes, and have a couple of points:
- part of the code is duplicated from method to method, it is more logical to group it into a separate method
- Initially, the task included a condition that it would be possible to configure filling in the fields for a response within a specific template, since often responses are not expected for email templates
Hi, @skoshelev . do you agree to add a new property named AllowToReply or AllowDirectReply to message templates.
When enabled it will allow admin to reply to the messages that is generated based on customer activity.
PS: What should this option mean for the emails that are sent to the customers?

Hi, @parshan2. Yes, let there be an AllowDirectReply field. Let's also fill in ReplyTo fields for user templates using the data of the mail account of the current template (if new settings is enabled)
i resolved thank you
Il giorno lun 20 feb 2023 alle ore 14:30 Sergey Koshelev < @.***> ha scritto:
Hi, @parshan2 https://github.com/parshan2. Yes, let there be an AllowDirectReply field. Let's also fill in ReplyTo fields for user templates using the data of the mail account of the current template (if new settings is enabled)
— Reply to this email directly, view it on GitHub https://github.com/nopSolutions/nopCommerce/issues/6167#issuecomment-1437030391, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADL6HTDDE7DC7RVO5VYMGLWYNWYVANCNFSM5QNCUR2Q . You are receiving this because you commented.Message ID: @.***>
@skoshelev filling ReplyTo fields with mail account data makes no sense. currently customer can reply to default sender that is the same as the sender mail account data.
Let me know if you have a better argument for that in mind.
I propose following methods to get ReplyToEmail and ReplyToName for most store owner templates:
/// <summary>
/// Get email and name to set ReplyTo property of email from customer
/// </summary>
/// <param name="messageTemplate">Message template</param>
/// <param name="customer">Customer</param>
/// <returns>Email address and name when reply to email</returns>
protected virtual async Task<(string email, string name)> GetCustomerReplyToNameAndEmail(MessageTemplate messageTemplate, Customer customer)
{
if (!messageTemplate.AllowDirectReply)
return ("", "");
var replyToEmail = await _customerService.IsGuestAsync(customer)
? string.Empty
: customer.Email;
var replyToName = await _customerService.IsGuestAsync(customer)
? string.Empty
: await _customerService.GetCustomerFullNameAsync(customer);
return (replyToEmail, replyToName);
}
/// <summary>
/// Get email and name to set ReplyTo property of email from order
/// </summary>
/// <param name="messageTemplate">Message template</param>
/// <param name="order">Order</param>
/// <returns>Email address and name when reply to email</returns>
protected virtual async Task<(string email, string name)> GetCustomerReplyToNameAndEmail(MessageTemplate messageTemplate, Order order)
{
if (!messageTemplate.AllowDirectReply)
return ("", "");
var billingAddress = await _addressService.GetAddressByIdAsync(order.BillingAddressId);
return (billingAddress.Email, $"{billingAddress.FirstName} {billingAddress.LastName}");
}
Hi @parshan2. I have no better argument than the consistency of behavior. if the AllowDirectReply setting for the template is enabled - fill in the ReplyTo data.
As for the implementation of the GetCustomerReplyToNameAndEmail methods, I have no special comments.
Thanks again for your help
Closed #6167