我想用C#以表格格式通过电子邮件发送屏幕截图,该表格格式存储在我的本地计算机中?
我想通过以表格电子邮件格式发送自动化过程中拍摄的屏幕截图来自动化我的工作。我已成功附加为文档,但我希望它以表格格式。这是我已经尝试过的代码我想用C#以表格格式通过电子邮件发送屏幕截图,该表格格式存储在我的本地计算机中?,c#,html,selenium,automation,C#,Html,Selenium,Automation,我想通过以表格电子邮件格式发送自动化过程中拍摄的屏幕截图来自动化我的工作。我已成功附加为文档,但我希望它以表格格式。这是我已经尝试过的代码 public static void email_send() { string htmlBody = "<html><body><h1>Picture</h1><br><img src=\"cid:test1.jpeg\"></body></
public static void email_send() {
string htmlBody = "<html><body><h1>Picture</h1><br><img src=\"cid:test1.jpeg\"></body></html>";
AlternateView avHtml = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);
LinkedResource inline = new LinkedResource("test1.jpeg", MediaTypeNames.Image.Jpeg);
inline.ContentId = Guid.NewGuid().ToString();
avHtml.LinkedResources.Add(inline);
Attachment att = new Attachment(@"D:/test123.png");
att.ContentDisposition.Inline = true;
MailMessage mail = new MailMessage();
mail.AlternateViews.Add(avHtml);
System.Net.Mail.SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("*****");
mail.To.Add("*******");
mail.Subject = "Test Mail - 1";
mail.Body = String.Format(
"<h3>Client: " + " Has Sent You A Screenshot</h3>" +
@"<img src=""cid:{0}"" />", inline.ContentId);
mail.IsBodyHtml = true;
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("******", "******");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
}
public static void email\u send(){
字符串htmlBody=“Picture
”;
AlternateView avHtml=AlternateView.createAlternateView-FromString(htmlBody,null,MediaTypeNames.Text.Html);
LinkedResource inline=新的LinkedResource(“test1.jpeg”,MediaTypeNames.Image.jpeg);
inline.ContentId=Guid.NewGuid().ToString();
avHtml.LinkedResources.Add(内联);
附件att=新附件(@“D:/test123.png”);
att.ContentDisposition.Inline=true;
MailMessage mail=新的MailMessage();
mail.AlternateViews.Add(avHtml);
System.Net.Mail.SmtpClient SmtpServer=新的SmtpClient(“smtp.gmail.com”);
mail.From=新的邮寄地址(“****”);
mail.To.Add(“*******”);
mail.Subject=“测试邮件-1”;
mail.Body=String.Format(
客户端:“+”已向您发送屏幕截图+
@“”,inline.ContentId);
mail.IsBodyHtml=true;
SmtpServer.Port=587;
SmtpServer.Credentials=新系统.Net.NetworkCredential(“*******”,“*******”);
SmtpServer.EnableSsl=true;
发送(邮件);
}
您错过了附件
您的链接资源也需要附加到电子邮件。您需要添加以下代码:
mail.Attachments.Add(att);