【发布时间】:2015-07-10 04:38:08
【问题描述】:
XElement doc = null;
doc = new XElement("root");
foreach (var content in emailContents)
{
doc.Add(new XElement("Email",
new XElement("FromAddress", content.FromAddress),
new XElement("EmailReceivedOn", content.receivedOnemail),
new XElement("Subject", content.subject),
new XElement("Body", content.body)));
// I want to add the below code after the body element is created in the xml inside the email element section; How to do the same?
foreach (var attachment in content.attachments)
{
doc.Add(new XElement("attachmentname"), attachment.Filename),
doc.Add(new XElement(("attachmentpath"), attachment.Filepath)
}
}
基本上 content.attachment 是附件名称列表,我想在正文元素之后添加列表。如何做同样的事情?
【问题讨论】:
-
只需分配
var email = new XElement("Email", ...);,然后添加到doc,然后添加附件?