SendEmail("message", "subject", new System.Net.Mail.Attachment(path1), new System.Net.Mail.Attachment(path2));
如何处理参数中的最后两个附件?完成后会自行处理吗?
答案 0 :(得分:7)
你不能,因为你没有引用它们。
将它们移到方法调用之外:
using (var attachment1 = new System.Net.Mail.Attachment(path1))
using (var attachment2 = new System.Net.Mail.Attachment(path2))
{
SendEmail("message", "subject", attachment1, attachment2);
}