我有两个DataTable
列:File
& Email
C#组数据行DataTable中
C://file1.jpg [email protected]
C://file2.jpg [email protected]
C://file3.jpg [email protected]
C://file4.jpg [email protected]
C://file5.jpg [email protected]
在通过DataRow
是我的代码,我环路和发送电子邮件至Email
附带File
。
问题:
我需要以某种方式检查是否有任何其他DataRow
s的相同Email
如果是这样,只需发送一个电子邮件与多个附件。
所以上面DataTable
将导致3封电子邮件:
file1,file2 sent to [email protected]
file3,file5 sent to [email protected]
file4 sent to [email protected]
我的代码示例:
foreach (DataRow row in dt.Rows) {
string file = row[0].ToString();
string email = row[1].ToString();
SendEmailWithAttachments(email,file);
}
我能通过一个StringCollection
或数组我SendEmailWithAttachments()
函数,那么循环throught它,重视所有的文件,但我如何将这些DataRow
s排在第一位
什么[GroupBy](https://msdn.microsoft.com/en-us/library/bb534304(v = vs.100).aspx)电子邮件? – Pikoh
可能首先要做的是改变_SendEmailWithAttachments_接受一个列表'与当前电子邮件的文件名 –
Steve