保存html更改
问题描述:
我的问题是,我想更改某些电子邮件的HTML中的某些src值。所有这些都已经完成了,我使用EWS api来建立连接,并使用html敏捷包进行解析。任何人都知道如何通过我对图像中的src值所做的更改来获取html?保存html更改
public static string parsearHtml(string body,Item item, ArrayList contentIDS, ArrayList urls)
{
string SRC = "";
int indice = 0;
string retorno = "";
//Console.WriteLine(body);
HtmlDocument email = new HtmlDocument();
email.LoadHtml(body);
foreach (HtmlNode img in email.DocumentNode.SelectNodes("//img"))
{
SRC = img.GetAttributeValue("src", null);
for (int i = 0; i < contentIDS.Count; i++)
{
if (SRC.Equals(contentIDS[i].ToString()))
{
indice = i;
break;
}
}
img.SetAttributeValue("src", urls[indice].ToString());
Console.WriteLine(img.GetAttributeValue("src", null));//in here i get the the attribute and its change so the changing of src values is working
//i tried email.save(retorno) but got error for empty path
//so i tried email.save(body) but got error for illegar characters in path
}
return retorno;
}
THX但随着内存流周围工作,它乌拉圭回合后反正感谢。顺便说一句,有任何想法如何在HTML中获取外部图像。知道我只是用附件做了解决方法。有任何想法如何获取参考图像,并将其转换为C#中的字节数组或图像对象? – rdk1992 2012-02-22 15:01:11
上午使用htmlagilitypack,我知道如何获得图像的src值,但我如何获取和存储该物理image.dont要存储在磁盘中。就像存储在字节数组中的附件一样。 – rdk1992 2012-02-22 15:02:05
要将图像下载到字节数组,可以使用WebClient类。 http://geekswithblogs.net/whiletrue/archive/2010/03/11/c-image-download.aspx有一个简单的例子 – arunes 2012-02-22 19:10:20