I am working on an Outlook add-in and have recently switched to C # for dating (I am a Java person at heart). At this point, I'm just trying to iterate through the mail folder and print the subject of each message on the console, mainly as a way to make sure everything is working fine so far. However, when I run it, I get the following error:
The operation failed. One or more parameter values ββare invalid.
Exception Text:
System.ArgumentException: Operation failed. One or more parameter values ββare not valid. in Microsoft.Office.Interop.Outlook.NameSpaceClass.GetFolderFromID (String EntryIDFolder, Object EntryIDStore) in OutlookAddIn2.ThisAddIn.ThisAddIn_Startup (object sender, EventArgs e) in Microsoft.Office.Tools.AddInuppl.OnStartOffart.Onartartffff .AddInImpl.AddInExtensionImpl.Microsoft.Office.Tools.EntryPoint.OnStartup () in Microsoft.Office.Tools.AddInBase.OnStartup () in OutlookAddIn2.ThisAddIn.FinishInitialization () in Microsoft.Office.Tools.Mdice.Off.Off.Base .EntryPoint.FinishInitialization () in Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.ExecutePhase (ExecutionPhases executionPhases) in Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.Microsoft.VisualStudio.Tools.Office.Runtime.Interop.IExecuteCustomization2.ExecuteEntryPoints ()
:
, , Microsoft MSDN, . , , , . , , , , !
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
namespace OutlookAddIn2
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Outlook.Folder pickFolder = (Outlook.Folder)Application.Session.PickFolder();
foreach (Outlook.MailItem oMailItem in pickFolder.Items)
{
Console.WriteLine(oMailItem.Subject);
}
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO generated code
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}