2

I am trying to set the dynamic mail subject, but it is not working.

I tried below ways.

1 <!--@subject Product Question : @--> {{ var sku }}<!-- from StoreName @-->

  1. <!--@subject Product Question : {{ var sku }} from StoreName @-->
  2. <!--@subject Product Question : @sku from StoreName @-->

But not working above ways.

<!--@subject {{var sku|raw }}@ " from StoreName"-->
<!--@vars
{"store url=\"\"":"Store Url",
"skin url=\"images/logo_email.gif\" _area='frontend'":"Email Logo Image"}
@-->
<!--@styles
body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
@-->
{{template config_path="design/email/header_template"}}
<div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
    <table cellspacing="0" cellpadding="0" border="0" width="100%">
        <tr>
            <td align="center" valign="top" style="padding:20px 0 20px 0">
                <table bgcolor="#FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
                    <tr>
                        <td valign="top">
                            <h1 style="font-size:22px;font-weight:normal;line-height:22px;margin:0 0 11px 0;">{{trans "Hello"}}, {{trans "Admin"}}</h1>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <table cellspacing="0" cellpadding="0" border="0" width="650">
                                <tr>
                                    <td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA; color:#504F50">
                                        <table style="width: 100%;">
                                            <tr>
                                                <td>
                                                     {{var message}}
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td>&nbsp;</td>
                                </tr>
                                </tbody>
                            </table>
                            <br/>
                            <br/>
                            <br/>
                            <table cellspacing="0" cellpadding="0" border="0" width="650">
                                <tr>
                                    <td valign="top" style="font-size:12px;border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA; color:#504F50">
                                         <p style="font-size:12px;margin:0;">
                                            <strong>{{trans "Thank you"}}</strong>
                                        </p>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                            <br/>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>
 {{template config_path="design/email/footer_template"}}

Any help on this will appreciate?

7
  • Have you got value of sku in body structure? Commented Feb 13, 2017 at 5:51
  • @Rakesh No I am trying..
    – Bojjaiah
    Commented Feb 13, 2017 at 5:52
  • @Rakesh Any help?
    – Bojjaiah
    Commented Feb 13, 2017 at 6:22
  • please show your template file where you have define above code. Commented Feb 13, 2017 at 6:26
  • 1
    you can just keep line <!--@subject {{var sku}} from StoreName @--> at top instead of your line Commented Feb 13, 2017 at 6:29

2 Answers 2

3

You have to kee below line in your template file to get dynamic value of sku in email template.

Just keep {{var sku}} in single state line same as below,

 <!--@subject {{var sku}} from StoreName @-->

Clear cache and check.

1
  • Hope you have like answer. Welcome. Commented Feb 13, 2017 at 6:45
3

I am Implementing a custom module and sending email by code mentioned in this Link

https://webkul.com/blog/magento-2-send-transactional-email-programmatically-in-your-custom-module/

To set Dynamic Subject I have replaced "@subject Subject Of your email " by "

@subject {{var subject|raw }}@ " in my html file which I put under NameSpace\Modulename\view\frontend\email\filename.html

Value to subject variable is passed from Helper file which is mentioned in the above link

1
  • I tried @subject {{var sku|raw }}@ " from YumWarehouse " but it is showing on body.
    – Bojjaiah
    Commented Feb 13, 2017 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.