我对如何使用它没有足够的想法。
目标:
1) 在dll中嵌入HTML文件
html 的内容为:
美好的一天!
您收到这封电子邮件是因为有人使用此电子邮件地址请求找回密码。 请访问以下链接开始该过程:
点击下面的链接
基本网址{}如果您没有提出此类请求,请忽略此电子邮件。
最好, 网站管理员
2) 每次我必须发送此电子邮件时,我都必须在嵌入的 html 中查找“BaseUrl{}”并将其替换为用于验证的链接。
3)我必须以html文件的形式发送文件,因为在进一步的开发中,我必须将图像放入文件中。
发送电子邮件的代码:
using System.Net.Mail;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public static void SendEmail(MailMessage mail)
{
SmtpClient client = new SmtpClient();
client.Host = "smtp.gmail.com";
client.Port = 123;
client.Credentials = new System.Net.NetworkCredential("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="23565046514d424e46634e424a4f0d404c4e" rel="noreferrer noopener nofollow">[email protected]</a>", "strongpassword");
client.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);
client.Send(mail);
}
private static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
if (sslPolicyErrors == SslPolicyErrors.None)
return true;
else
{
ServiceFault.WriteLog("Invalid SSL");
return true;
}
}
或者您可以给我教程链接,或者如果您有更好的建议,请告诉我。
谢谢!
最佳答案
我认为对 URI 使用字符串替换的策略很好。
为了将其嵌入到您的 DLL 中:
1) 创建一个包含所需内容的文件。
2) 将资源文件添加到您的项目中。
3) 添加"file"类型资源(“添加现有文件”选项)并选择您的文件(这会将您的文件复制到您的项目中。
4) 在您的代码中,使用自动生成资源访问器访问该嵌入文件的内容。
关于c# - 如何在dll中嵌入html文件并稍后编辑内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8663701/