如何在C#中发送outlook邮件正文中的gridview数据 [英] how to send gridview data in outlook mail body in C#
问题描述
如何在C#中发送Outlook邮件正文中的gridview数据
how to send gridview data in outlook mail body in C#
outlook.Application oApp = new outlook.Application();
outlook.MailItem oMsg = (outlook.MailItem)oApp.CreateItem(outlook.OlItemType.olMailItem);
outlook.Inspector oInspector = oMsg.GetInspector;
oMsg.HTMLBody = "Dear Sir, <br/> Please Assign the Priority for Scaffolding Jobs...!!<br/>";
oMsg.Subject =来自脚手架工作的新请求;
outlook.Recipients oRecips =(outlook.Recipients)oMsg.Recipients;
outlook.Recipient oRecip =(outlook.Recipient)oRecips.Add(Safihur@fabtech.ae );
oRecip.Resolve();
oMsg.Send();
oRecip = null;
oRecips = null;
oMsg = null;
oApp = null;
oMsg.Subject = "New Request from Scaffolding Jobs";
outlook.Recipients oRecips = (outlook.Recipients)oMsg.Recipients;
outlook.Recipient oRecip = (outlook.Recipient)oRecips.Add("Safihur@fabtech.ae");
oRecip.Resolve();
oMsg.Send();
oRecip = null;
oRecips = null;
oMsg = null;
oApp = null;
推荐答案
尝试下面
try below
StringBuilder emailBody = new StringBuilder();
StringWriter sw = new StringWriter(emailBody);
HtmlTextWriter hw = new HtmlTextWriter(sw);
gridView1.RenderControl(hw);
oMsg.HTMLBody = "Dear Sir, <br /> Please Assign the Priority for Scaffolding Jobs...!!<br />" +
emailBody.ToString();
check以下帖子,了解如何从gridview生成html。
如何使用C#,VB.NET在Asp.Net中的电子邮件正文中发送Gridview [ ^ ]
查看下面的KB文章
如何使用Microsoft Outlook对象库通过Visual C#发送HTML格式的邮件 [ ^ ]
这篇关于如何在C#中发送outlook邮件正文中的gridview数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!