电子邮件表格中的插入功能和Enmail收件人表格中的电子邮件ID插入
public void InsertEmailsFromIMAP(string SelectMailBox, string Server, string AccountId, string Password, int DefaultPort, bool EnableSSL, int EmailFolderId, long EmailAccountId)
{
try
{
using (var imap = new AE.Net.Mail.ImapClient(Server, AccountId, Password, AE.Net.Mail.ImapClient.AuthMethods.Login, DefaultPort, EnableSSL))
{
imap.SelectMailbox(SelectMailBox);
MailMessage[] messagetrash = imap.GetMessages(0, 10, false);
foreach (MailMessage msgitemtrash in messagetrash)
{
EmailFolder objEmailfolder = db.EmailFolders.Where(EF => EF.EmailFolderId == EmailFolderId).FirstOrDefault();
Email objEmail = new Email();
objEmail = GetEmailsData(EmailAccountId, objEmailfolder.EmailFolderId, msgitemtrash.Subject, msgitemtrash.Body, msgitemtrash.Date, msgitemtrash.From.ToString());
db.Emails.AddObject(objEmail);
db.SaveChanges();
//WriteText("Bcc"+msgitemtrash.Bcc.ToString()+"<br>");
//WriteText("Ccc"+msgitemtrash.Cc.ToString()+"<br>");
//WriteText("To"+msgitemtrash.To.ToString());
long EmailId = objEmail.EmailId;
int EmailrecipientType = 0;
if (msgitemtrash.To.ToString() != "")
EmailrecipientType = 1;
else if (msgitemtrash.Bcc.ToString() != "")
EmailrecipientType = 2;
else if (msgitemtrash.Cc.ToString() != "")
EmailrecipientType = 3;
WriteText(EmailrecipientType.ToString());
WriteText(EmailId.ToString());
EmailRecipient objEmailRecipient = new EmailRecipient();
objEmailRecipient = GetEmailRecipientData(EmailId,EmailrecipientType );
db.EmailRecipients.AddObject(objEmailRecipient);
db.SaveChanges();
}
imap.Dispose();
}
}
catch(Exception ex)
{
WriteText(ex.ToString());
}
}
当插入收件人表时,其给出错误System.Collections.Generic.List。如何转换集合类型以及数据库列名中的类型。