【发布时间】:2014-06-16 14:13:56
【问题描述】:
我正在开发一个正在更新跟踪表单的库存应用程序系统,并且我最近从 System.Web.Mail 转换为 System.Net.Mail。
但是,关于我在物品转移失败时处理的异常 if-else 语句,我得到:
“无法将类型'string'隐式转换为'System.Net.Mail.MailAddressCollection” 以下代码块出错:
else //If the Item Transfer Fails
{
_formToUpdate.WorkFlowStep = "d";
_formToUpdate.InventoryCertifier_Initials = dbcontext.Custodies.Where(x => x.Custody_eraider == User.Identity.Name.ToLower()
_formToUpdate.InventoryCertifierInitials_DtTm = DateTime.Now;
_formToUpdate.IsFormLockedforEditing = true;
//The notification lists are different in both cases.
NotificationEmail.To = dbcontext.Custodies.Where(x => x.Custody_eraider ==
_formToUpdate.TransferFrom_Sign).Single().Custody_Email + ","
+ dbcontext.Custodies.Where(x => x.Custody_eraider == _formToUpdate.TransferTo_Sign).
Single().Custody_Email + "," + dbcontext.Custodies.Where(x => x.Custody_eraider ==
_formToUpdate.Form_Approv_Reject_By).Single().Custody_Email + ","
+ dbContext.Custodies.Where(x => x.Custody_eraider == _formToUpdate.InventoryCertifier_
Initials).Single().Custody_Email;
}
错误只发生在以 NotificationEmail.To = ... 开头的代码部分中
我只是不太确定如何正确修改该声明。
任何帮助将不胜感激。如果我需要提供更详细的信息,请告诉我。谢谢!
【问题讨论】:
-
顺便说一句,我已经将 NotificationEmail 声明为: var NotificationEmail = new MailMessage();我没有把那部分代码放进去,因为下面大约有 100-120 行不适用于我遇到的问题。只是想澄清 NotificationEmail 已声明。
标签: type-conversion system.net.mail