简体   繁体   中英

Add 2 parameters to Email Template Body

I have a email template and i have bind 1 parameter to it(this.OrderCode) and it's working .So now i need to bind another one.

Email Template Like Below,

string OrderTemplate="<p><%=this.OrderCode%></p><p><%=this.ReferredTo%></p>";

tempValues comes like below,
[0]this.OrderCode
[1]ODR5000
[2]this.ReferredTo
[3]Janez Smithson

Using below code i need to show both of above values.In here only shows 1st value only(ODR5000)

public string EmailTemplate(string OrderTemplate, params string[] tempValues)
        {
            string templatebody = string.Empty;
            try
            {
                templatebody = OrderTemplate;
                for (var i = 0; i < tempValues.Length; i++)
                {
                    templatebody= templatebody.Replace("<%={0}%>".FormatWith(tempValues[i]), tempValues++);
                }
            }
            catch (Exception ex)
            {
                throw ex;
                Log4NetLogger.Log(ex);
            }
            return templatebody;
        }

I have pretty similar function for that.

for (int i = 0; i < tempValues.Length; i++)
{
    var pattern = string.Format(@"(\[{0}\])", i);
    templatebody = Regex.Replace(templatebody, pattern, tempValues[i].ToString());
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM