如何在sql表中存储和检索邮件正文 [英] how to store and retrive email body in sql table

查看:57
本文介绍了如何在sql表中存储和检索邮件正文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想存储和回复邮件正文,电子邮件包含表格,网址链接。



i我在sql表文本栏中将电子邮件正文存储为字符串。



如何使用所有表格,链接,网址检索电子邮件。



谢谢..

解决方案

您可以使用ADO.Net代码从数据库中获取数据。看看SqlClient命名空间下的类和方法。


试一试



  //  使用此图书馆[从互联网下载]  
使用 HtmlAgilityPack;





  string  sReturn =  string  .Empty; 

HtmlDocument htmldoc = new HtmlDocument();
htmldoc.LoadHtml(HtmlString);

// 获取HTML PAGE中所有链接的网址
IEnumerable< HtmlNode> hn = htmldoc.DocumentNode.Descendants();
foreach (HtmlNode nd in hn)
{

if (nd.Name.ToLower()== a
{
sReturn + = nd.Attributes [ href]。值+ @ \\\\ n;
}
}

// 现在使用sReturn变量


// 获取所有输入字段的值
IEnumerable< HtmlNode> hn = htmldoc.DocumentNode.Descendants();
foreach (HtmlNode nd in hn)
{

if (nd.Name.ToLower()== 输入
{
sReturn + = nd.Attributes [ ]。值+ @ \\\\ n;
}
}

// 现在使用sReturn变量


Hi all,

I want to store and retrive email body, email contains tables, url links.

i am storing email body as string in sql table text column.

how to retrive email with all tables, links,urls.

thanks..

解决方案

You can use ADO.Net code get the data from database. Take a look at classes and methods under SqlClient namespace.


Try it

// USE THIS LIBRARY [DOWNLOAD FROM INTERNET]
using HtmlAgilityPack;



string sReturn = string.Empty;

HtmlDocument htmldoc = new HtmlDocument();
htmldoc.LoadHtml(HtmlString);

// TO GET URL OF ALL LINKS IN HTML PAGE
IEnumerable<HtmlNode> hn = htmldoc.DocumentNode.Descendants();
foreach (HtmlNode nd in hn)
{

	if (nd.Name.ToLower() == "a")
        {
        	sReturn += nd.Attributes["href"].Value + @"\r\n";
	}
}

// NOW USE "sReturn" Variable


// TO GET VALUE OF ALL INPUT FIELDS
IEnumerable<HtmlNode> hn = htmldoc.DocumentNode.Descendants();
foreach (HtmlNode nd in hn)
{

	if (nd.Name.ToLower() == "input")
        {
        	sReturn += nd.Attributes["value"].Value + @"\r\n";
	}
}

// NOW USE "sReturn" Variable


这篇关于如何在sql表中存储和检索邮件正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆