Outlook interop GetSharedDefaultFolder由于注册表或安装问题,操作失败。 [英] Outlook interop GetSharedDefaultFolder The operation failed because of a registry or installation problem.
问题描述
我的开发PC(Windows XP with Office 2010)上的代码运行良好。但是当我在带有Office 2010的Windows 7 PC上运行可执行文件时,我收到以下错误:
由于注册表或安装问题导致操作失败。重新启动Outlook并重试。如果问题坚持,重新安装。
错误发生在这一行:
Dim inbox As Folder = ns.GetSharedDefaultFolder(收件人,OlDefaultFolders.olFolderInbox) )
我有一个单独的应用程序在同一台生产PC上运行,使用Microsoft.Office.Outlook.Interop将.MSG文件转换为.PDF,运行没有问题。
Imports Microsoft.Office.Interop.Outlook
log = 新 cLog()
Dim AppKeys As IDictionary = ConfigurationManager.GetSection( AppKeys)
Dim app As 新 Microsoft.Office.Interop .Outlook.Application()
Dim 框作为 字符串
log.Write( 开始检索邮件。)
尝试
box = AppKeys( 邮箱)
tempLoc = Environment.CurrentDirectory& \& ConfigurationManager.AppSettings( TempLoc)
Dim ns As Microsoft.Office.Interop.Outlook。 NameSpace = app.Session
log.Write( 命名空间为:& ns.CurrentProfileName)
< span class =code-keyword> Dim 收件人 As 收件人= ns.CreateRecipient(方框)
log.Write( 收件人是:& recipient.Name)
recipient.Resolve()
log。写( 收件人已解决)
Dim inbox As Folder = ns.GetSharedDefaultFolder(收件人, OlDefaultFolders.olFolderInbox)
log.Write( 收件箱)
< span class =code-keyword> Dim subject As String
< span class =code-keyword> Dim mailCount As Int32 = 0
log.Write( 有 + inbox.Items.Count.ToString()+ + box中的电子邮件
对于 每个 mm As MailItem 在 inbox.Items
如果 不 subject 什么 然后
对于 每个附加作为附件在 mm.Attachments
attach.SaveAsFile(tempLoc&文件名和attach.FileName.Substring(attach.FileName.Length - 4 , 4 ))
< span class =code-keyword>下一步
' '将电子邮件另存为msg和为它创建idx文件
filename = filename.Substring( 0 ,filename.Length - 2 )& _& count + 1
mm.SaveAs(tempLoc& filename& 。msg,OlSaveAsType.olMSG)
结束 如果
下一步
Catch ex As System.Exception
log.Write( Excpetion getting mail:& ex.Message)
结束 尝试
app.Quit()
任何想法都将不胜感激。
谢谢,
tshaffer
开始遇到同样的错误了昨天在Outlook VBA中。终于找到了解决方法。
改变了这个:
设置 teamBox = objNS.CreateRecipient( Our.Shared.Mailbox@domain.tld )
设置 olTeamBoxItems = objNS.GetSharedDefaultFolder(teamBox,olFolderInbox).Items
对此:
设置 olTeamBoxItems = objNS.Folders( 我们的共享邮箱)。文件夹( 收件箱)。Items
在C#中使用Outlook = Microsoft.Office.Interop.Outlook,我的解决方案看起来像这样:
Outlook.NameSpace nameSpace = olApp.GetNamespace(Mapi);
Outlook.MAPIFolder inbox =(Outlook.MAPIFolder )nameSpace.Folders [共享文件夹]。文件夹[我NBOX];
I have the following code working well on my Development PC (Windows XP with Office 2010). But when I run the executable on a Windows 7 PC with Office 2010, I get the following error:
"The operation failed because of a registry or installation problem. Restart Outlook and try again. If the problem persists, reinstall."
The error happens on this line:
Dim inbox As Folder = ns.GetSharedDefaultFolder(recipient, OlDefaultFolders.olFolderInbox)
I have a seperate application running on the same production PC that uses Microsoft.Office.Outlook.Interop to convert .MSG files to .PDF that runs without issue.
Imports Microsoft.Office.Interop.Outlook
log = New cLog()
Dim AppKeys As IDictionary = ConfigurationManager.GetSection("AppKeys")
Dim app As New Microsoft.Office.Interop.Outlook.Application()
Dim box As String
log.Write("Starting to retrieve mail.")
Try
box = AppKeys("mailbox")
tempLoc = Environment.CurrentDirectory & "\" & ConfigurationManager.AppSettings("TempLoc")
Dim ns As Microsoft.Office.Interop.Outlook.NameSpace = app.Session
log.Write("Namespace is: " & ns.CurrentProfileName)
Dim recipient As Recipient = ns.CreateRecipient(box)
log.Write("recipient is: " & recipient.Name)
recipient.Resolve()
log.Write("recipient resolved")
Dim inbox As Folder = ns.GetSharedDefaultFolder(recipient, OlDefaultFolders.olFolderInbox)
log.Write("Got inbox")
Dim subject As String
Dim mailCount As Int32 = 0
log.Write("There are " + inbox.Items.Count.ToString() + " Emails in " + box)
For Each mm As MailItem In inbox.Items
If Not subject Is Nothing Then
For Each attach As Attachment In mm.Attachments
attach.SaveAsFile(tempLoc & filename & attach.FileName.Substring(attach.FileName.Length - 4, 4))
Next
''Save email message as msg and create idx file for it
filename = filename.Substring(0, filename.Length - 2) & "_" & count + 1
mm.SaveAs(tempLoc & filename & ".msg", OlSaveAsType.olMSG)
End If
Next
Catch ex As System.Exception
log.Write("Excpetion getting mail: " & ex.Message)
End Try
app.Quit()
Any thoughts would be greatly appreciated.
Thank you,
tshaffer
Started experiencing the same error out of the blue yesterday in Outlook VBA. Finally found a workaround.
Changed this:
Set teamBox = objNS.CreateRecipient("Our.Shared.Mailbox@domain.tld") Set olTeamBoxItems = objNS.GetSharedDefaultFolder(teamBox, olFolderInbox).Items
To this:
Set olTeamBoxItems = objNS.Folders("Our Shared Mailbox").Folders("Inbox").Items
In C# using Outlook = Microsoft.Office.Interop.Outlook, my solution looked like this:
Outlook.NameSpace nameSpace = olApp.GetNamespace("Mapi");
Outlook.MAPIFolder inbox = (Outlook.MAPIFolder)nameSpace.Folders["The Shared Folder"].Folders["Inbox"];
这篇关于Outlook interop GetSharedDefaultFolder由于注册表或安装问题,操作失败。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!