我正在尝试向我的同事发送邮件,但在第一封邮件之后,应用程序崩溃了。我收到这条消息
COMException 未被用户代码处理。 “该项目已被移动或删除。”
private void SendMail()
{
var usersEmailAddresses = Factory.Users.List(); // .List() lists all the data from the Users table.
Application OutlookApplication = new Application();
MailItem OutlookMail = (MailItem)OutlookApplication.CreateItem(OlItemType.olMailItem);
OutlookMail.Subject = @"TEST/Ushqimi i caktuar per sot";
MailBody //region, here I assign the MailBody Text.
for (int index = 0; index < usersEmailAddresses.Count; index++)
{
OutlookMail.To = usersEmailAddresses[index].Email; //Here is where I get the exception, AFTER trying to assign the second email.
if (usersEmailAddresses[index].RecieveEmail && !usersEmailAddresses[index].IsOnVacation)
{
((_MailItem)OutlookMail).Send();
}
}
}
我究竟做错了什么?有什么建议么?