简体   繁体   English

在HTML电子邮件c#MVC中通过href传递参数

[英]Pass Parameter with href inside HTML Email c# MVC

I am trying to send email using my MVC Javascript application.for now email is sending and my hrefs are clickable and redirect to correct link.but my problem is how can i pass parameters with the href 我正在尝试使用我的MVC Javascript应用程序发送电子邮件。目前,电子邮件正在发送,我的href是可单击的,并重定向到正确的链接。但是我的问题是我如何通过href传递参数

emailBody += @"
        </tbody>
    </table>
    <br />
    <h3><b>Currently Data;</b></h3>
    <table>
        <thead>
            <tr style='color: #ed5565; text-align: center'>
                <th>Completed Date</th>
                <th>Category</th>

            </tr>
        </thead>
        <tbody>";

            for (int i = 0; i < result3.Count; i++)
            {
                emailBody += @"
            <tr style='text-align: center'>
            <a href='http://myTestLink.com/Forms/Upload/' + result3[i].FormID >
                 <td>" + result3[i].CompletedDate + @"</td>
                <td>" + result3[i].FormCategory + @"</td>

</a>
            </tr>";
            }

This is for href attributes: "' ... '" 这是href属性: "' ... '"

emailBody += @"
    </tbody>
</table>
<br />
<h3><b>Currently Data;</b></h3>
<table>
    <thead>
        <tr style='color: #ed5565; text-align: center'>
            <th>Completed Date</th>
            <th>Category</th>

        </tr>
    </thead>
    <tbody>";

        for (int i = 0; i < result3.Count; i++)
        {
            emailBody += @"
        <tr style='text-align: center'>
        <a href="'http://myTestLink.com/Forms/Upload/'" + result3[i].FormID + ">
             <td>" + result3[i].CompletedDate + @"</td>
            <td>" + result3[i].FormCategory + @"</td>

You need to make dynamic code for href for passing parameter. 您需要为href制作动态代码以传递参数。

emailBody += @"
        </tbody>
    </table>
    <br />
    <h3><b>Currently Data;</b></h3>
    <table>
        <thead>
            <tr style='color: #ed5565; text-align: center'>
                <th>Completed Date</th>
                <th>Category</th>

            </tr>
        </thead>
        <tbody>";

            for (int i = 0; i < result3.Count; i++)
            {
                emailBody += @"
            <tr style='text-align: center'>
            <a href='http://myTestLink.com/Forms/Upload/'" + result3[i].FormID + ">" +
                 "<td>" + result3[i].CompletedDate + @"</td>
                <td>" + result3[i].FormCategory + @"</td>

</a>
            </tr>";
            }

你可以试试看

<a href='@string.Format("http://myTestLink.com/Forms/Upload/' + result3[i].FormID", result3[i].FormID)'>

您也可以尝试

 <a href='@string.Format("http://myTestLink.com/Forms/Upload?formId=' + result3[i].FormID", result3[i].FormID)'>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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