Outlook Interop 2010 C#将项目移动到共享的OlDefaultFolders.olFolderSentMail

时间:2011-05-05 13:36:03

标签: c# interop outlook

发生了奇怪的事情。我正在尝试使用GetSharedDefaultFolder从本地MAPI文件夹复制并移动项目到remtoe已发送邮件文件夹。它适用于收件箱文件夹,但不适用于已发送的项目,即使我有权限。任何想法都会非常感谢你。

错误是'无法完成操作。一个或多个参数值无效'

代码示例是:

Outlook.MailItem cItem = (mailmsg as Outlook.MailItem).Copy() as Outlook.MailItem;
Outlook.NameSpace ns = this.Application.GetNamespace("MAPI");
//ns.Logon()
Outlook.Recipient recipient = ns.CreateRecipient("realusera@domain.com");
recipient.Resolve();
if (recipient.Resolved)
{
    MessageBox.Show("Resolved user");
    Outlook.MAPIFolder mapifld = ns.GetSharedDefaultFolder(recipient, Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderSentMail);
    cItem = (Outlook.MailItem)cItem.Move(mapifld);
}

1 个答案:

答案 0 :(得分:1)

根据此API的MS文档,olFolderSentMail是不允许的默认文件夹之一。

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._namespace.getshareddefaultfolder.aspx

摘录:

FolderType可以是以下OlDefaultFolders常量之一:olFolderCalendar,olFolderContacts,olFolderDrafts,olFolderInbox,olFolderJournal,olFolderNotes或olFolderTasks。 (不能为此参数指定常量olFolderDeletedItems,olFolderOutbox,olFolderJunk,olFolderConflicts,olFolderLocalFailures,olFolderServerFailures,olFolderSyncIssues,olPublicFoldersAllPublicFolders,olFolderRssSubscriptions,olFolderToDo,olFolderManagedEmail和 olFolderSentMail 。)