を使用して、私はそれがWindows 7の64ビット列挙見通しメールボックスのVisual Studioに
using System;
using System.Windows;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Outlook;
namespace MarketingEmails
{
public class MailUtils
{
public static string[] processMailMessages(object outlookFolder)
// Given an Outlook folder as an object reference, return
// a list of all the email subjects in that folder
{
// Set a local object from the folder passed in
Folder theMailFolder = (Folder)outlookFolder;
string[] listSubjects = new string[theMailFolder.Items.Count];
int itemCount = 0;
// Now process the MAIL items
foreach (MailItem oItem in theMailFolder.Items)
{
listSubjects[itemCount] = oItem.Subject.ToString();
itemCount++;
}
return listSubjects;
}
}
上で実行されているOutlook 2007の反対のVisual Studio 2008でフォルダ
にすべての電子メールの件名を返すように意図された以下のクラスを持っていますコードは以下の例外スローしかし
}
:
タイプのCOMオブジェクトをキャストすることができません「をシステム.__ ComObject」内に'Microsoft.Office.Interop.Outlook.MailItem'という接頭辞タイプです。 IID「{00063034-0000-0000-C000-000000000046}」とのインターフェースのためのCOMコンポーネントのQueryInterfaceを呼び出し、次のエラーが原因で失敗したため、この操作が失敗しました:そのようなインタフェースは、(:0x80004002の(E_NOINTERFACE)HRESULTからの例外)をサポートしません。
私は選択されたメールボックスにReportItemを処理しようとしているため、エラーが発生していることを理解しています。
私が指定したときはそれがROプロセス非メールアイテムをしようとしている理由を私は理解していないこと次のとおりです。
foreach (MailItem oItem in theMailFolder.Items)
私はそれがメールボックスにアイテムを報告するエントリを処理したい場合は、私が持っているでしょう書かれた:これはバグである場合は、それはちょうど私のミスの理解
よろしくいる場合
foreach (ReportItem oItem in theMailFolder.Items)
私は心から知りたいです、 Nigel Ainscoe
これは治療に感謝します - ありがとう –
ああ素敵なトリックJaredParは非常にクールです。 –