Manohar Ch
Manohar Ch

Reputation: 465

Sending mails to CC address in Hybris

I am trying to implement the functionality to send Order Confirmation mail to multiple recipients in CC. Anyone have idea please help.

Thanks in advance.

Upvotes: 2

Views: 1081

Answers (1)

Hristo Staykov
Hristo Staykov

Reputation: 974

one solution is to extend the de.hybris.platform.acceleratorservices.email.impl.DefaultEmailGenerationService . There is a method createEmailMessage which generates and returns a EmailMessageModel in the generate method. On this MessageModel, you can set the needed properties. An example code snippet would be something like this.

public class MyEmailGenerationService extends DefaultEmailGenerationService implements EmailGenerationAndSendService {
   @Override
    public EmailMessageModel generate(final BusinessProcessModel businessProcessModel, final EmailPageModel emailPageModel)
            throws RuntimeException {
                 //Make a check for your businessProcessModel if it is 
            if (businessProcessModel instanceof OrderProcessModel) {
                 EmailMessageModel myCustomMessage = super.createEmailMessage("Your Subject", "Your body", emailContext);
                 myCustomMessage.setCcAddresses(new ArrayList<EmailAddressModel>()); // Here add the list of the cc you want to send.
            }
        }
}

Upvotes: 5

Related Questions