nopCommerce icon indicating copy to clipboard operation
nopCommerce copied to clipboard

Add Reply-To for Order Notification Email

Open RomanovM opened this issue 3 years ago • 3 comments

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.

RomanovM avatar Mar 10 '22 16:03 RomanovM

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.

RogerSmithR avatar Apr 07 '22 01:04 RogerSmithR

If this task has no assignee. I would love to be assigned to it.

ChrisClaude avatar May 11 '22 21:05 ChrisClaude

@ChrisClaude Please feel free to make to make a pull request

AndreiMaz avatar May 12 '22 03:05 AndreiMaz

i have the same problem

micolf avatar Dec 08 '22 18:12 micolf

@RomanovM do you have find a solution?

micolf avatar Dec 08 '22 18:12 micolf

I have filled out replyToEmailAddress and replyToName parameter of SendNotificationAsync method for most admin email messages. @skoshelev any suggestion!

parshan2 avatar Feb 09 '23 10:02 parshan2

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

skoshelev avatar Feb 14 '23 08:02 skoshelev

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?

image

parshan2 avatar Feb 20 '23 07:02 parshan2

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)

skoshelev avatar Feb 20 '23 13:02 skoshelev

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: @.***>

micolf avatar Feb 20 '23 15:02 micolf

@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}");
    }

parshan2 avatar Feb 22 '23 12:02 parshan2

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

skoshelev avatar Mar 01 '23 07:03 skoshelev

Closed #6167

skoshelev avatar Mar 10 '23 09:03 skoshelev