由于正常的邮件,你必须发送邮件的正文内容像下面
你的C#代码。
string _FilePath = HttpContext.Server.MapPath("Activation.txt");
StreamReader sr = new StreamReader(_FilePath);
string body = sr.ReadToEnd();
sr.Close();
sr.Dispose();
发送上述体在电子邮件的正文
您Activation.txt文件中的代码将是一个模板,如下面只是身体标记
<body style="margin: 1% 10%;">
<table style="position:relative;background-color: whitesmoke;padding-bottom: 20px;text-align: center;width: 100%;">
<tbody class="">
<tr class="">
<td style="position:relative;top:20px;padding-left: 25px;padding-right: 25px;margin-right: auto;margin-left: auto;" width="400" align="center" bgcolor="whiteSmoke">
<img src="[HLINK]" height="70" width="150" alt="image cannot displayed ">
</td>
</tr>
<tr>
<td width="400" align="center" bgcolor="whiteSmoke"></td>
</tr>
<tr>
<td align="center" style="position: relative; top: 11px; padding-left: 25px; padding-right: 25px; margin-right: auto; margin-left: auto;" width="470" bgcolor="whitesmoke">
<h2 style="
color:#f44336;
font-family: WeblySleek UI,Segoe UI,Helvetica Neue,Arial,sans-serif">
Hey thanks for joining<h2 /> <h4 style="font-family: WeblySleek UI,Segoe UI,Helvetica Neue,Arial,sans-serif;">Welcome to Portal! Before you get started, please verify your email address below </h4>
</td>
</tr>
<tr bgcolor="whitesmoke" style="position:relative;top:9px;">
<td align="center" style="position:relative;top:-4px;padding-left: 25px;padding-right: 25px;margin-right: auto;margin-left: auto;">
<a style="position:relative;display: block;width:150px;height: 20px;text-align:center; text-decoration:none;background:#f44336;padding:10px;border-radius: 5px;color: white;font-family: WeblySleek UI,Segoe UI,Helvetica Neue,Arial,sans-serif;" href="[HLink]">Verify Email Address</a>
</td>
</tr>
<tr>
<td style="position:relative;top:3px;padding-left: 25px;padding-right: 25px;margin-right: auto;margin-left: auto;" bgcolor="whitesmoke" align="center" width="400">
<span style="padding-left:0.3cm;font-family: WeblySleek UI,Segoe UI,Helvetica Neue,Arial,sans-serif;">Thank you for visiting Us. It is the ultimate gift of choice.You can send to a friend or loved one with a selection of brands to pick from in various categories such as fashion, beauty, sports, food, entertainment etc. <span>
</td>
</tr>
<tr>
<td style="position:relative;padding-left: 25px;padding-right: 25px;margin-right: auto;margin-left: auto;" bgcolor="whitesmoke">
<h2 style="color:#f44336;font-family: WeblySleek UI,Segoe UI,Helvetica Neue,Arial,sans-serif;" align="center">Our Most Celebrated Brands</h2>
</tr>
<tr>
<td style="position:relative;top:-2px;padding-left: 25px;padding-right: 25px;margin-right: auto;margin-left: auto;" align="center" bgcolor="whitesmoke" width="400" style="padding:10px;">
<b style="font-family: WeblySleek UI,Segoe UI,Helvetica Neue,Arial,sans-serif;">Contact Us:</b> <img src="http://img/phone.png"> <span>987654321</span> <img src="http://img/email.jpg"> <span styl="font-family: WeblySleek UI,Segoe UI,Helvetica Neue,Arial,sans-serif;">[email protected]</span>
</td>
</tr>
<tr>
<td style="background-color:whitesmoke;position:relative;text-align: center;">
<span>
<a style="position:relative;padding:10px 30px;text-align:center; text-decoration:none;background:#4e69a2;border-radius: 5px;color: white;font-family: WeblySleek UI,Segoe UI,Helvetica Neue,Arial,sans-serif;" href="#">Facebook</a>
<a style="position:relative;padding:10px 30px;text-align:center;text-decoration:none;background:#c32f10;border-radius: 5px;color: white;font-family: WeblySleek UI,Segoe UI,Helvetica Neue,Arial,sans-serif;" href="#">Google</a>
</span>
</td>
</tr>
</tbody>
</table>
</body>
您还可以动态地添加/替换要在电子邮件中发送的数据 在后端添加以下代码
body = body.Replace("[HLink]", YOUR-DATA);
[如何呈现PDF格式的ASP.NET MVC视图]可能的副本(https://stackoverflow.com/questions/1324597/how-to-render-an-asp-net-mvc-view-in -pdf格式) –