私は Outlook アドインに取り組んでおり、最近慣れるために C# に切り替えました (私は根っからの Java マンです)。この時点で、メール フォルダーを反復処理し、各メッセージの件名をコンソールに出力しようとしています。これは主に、これまでのところすべてが正常に機能していることを確認する方法です。ただし、実行するたびに、次のエラーが表示されます。
操作を完了できませんでした。1 つ以上のパラメーター値が無効です。
例外テキスト:
System.ArgumentException: 操作を完了できませんでした。1 つ以上のパラメーター値が無効です。Microsoft.Office.Interop.Outlook.NameSpaceClass.GetFolderFromID (文字列 EntryIDFolder、オブジェクト EntryIDStore) で OutlookAddIn2.ThisAddIn.ThisAddIn_Startup (オブジェクトの送信者、EventArgs e) で Microsoft.Office.Tools.AddInImpl.OnStartup() で Microsoft.Office.Tools .AddInImpl.AddInExtensionImpl.Microsoft.Office.Tools.EntryPoint.OnStartup()、Microsoft.Office.Tools.AddInBase.OnStartup()、OutlookAddIn2.ThisAddIn.FinishInitialization()、Microsoft.Office.Tools.AddInBase.Microsoft.Office.Tools .EntryPoint.FinishInitialization() Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.ExecutePhase(ExecutionPhases executionPhases) で Microsoft.VisualStudio.Tools.Office.Runtime.
読み込まれたアセンブリ:
これは、ユーザーにフォルダーを選択させるために MSDN で Microsoft が推奨している正確な方法であるため、これにはやや困惑しています。ソースを含めました。ご意見がありましたらお知らせください。この投稿を読んでくれてありがとう、そして喜んで手伝ってくれてありがとう!
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)
{
//Get application namespace and grab the original folder object
Outlook.Folder pickFolder = (Outlook.Folder)Application.Session.PickFolder();
//Outlook.Folder mrFolder = Application.Session.GetFolderFromID(pickFolder.EntryID, pickFolder.StoreID) as Outlook.Folder;
foreach (Outlook.MailItem oMailItem in pickFolder.Items)
{
Console.WriteLine(oMailItem.Subject);
}
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}