rpc服务器不可用邮件,Outlook Interop“RPC服务器不可用”当电子邮件打开

该博客讨论了一个使用OutlookInterop库创建的程序遇到的问题,即在尝试打开邮件时出现'RPC服务器不可用'的错误。问题表现为打开多封邮件后,Outlook图标从任务栏消失。作者提供了问题的详细步骤和可能的异常情况,并提到该问题可能与Outlook进程的管理有关。解决方案建议检查Windows应用程序日志以获取更多线索。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用Outlook Interop,我创建了一个小应用程序连接到我的Outlook收件箱并收集30封电子邮件,然后将它们显示在网格中。当您双击网格中的电子邮件时,它将在Outlook中打开电子邮件。Outlook Interop“RPC服务器不可用”当电子邮件打开

在应用程序中: - 打开一封电子邮件,尽量减少它。然后打开另一个,它会打开罚款。 - 打开电子邮件,关闭它。然后打开另一个,你会得到'RPC服务器不可用。 (来自HRESULT的例外: 0x800706BA)'错误。

我注意到发生这种情况时,系统托盘中的Outlook图标消失。

我正在运行的Office 2010

有谁知道如何解决这个问题?

Imports Microsoft.Office.Interop.Outlook

Imports System.Runtime.InteropServices

Imports System.Reflection

Public Class Form1

Private m_outlookApplication As Application 'Outlook

Private m_nameSpace As Microsoft.Office.Interop.Outlook.NameSpace 'Outlook's namespace

Private WithEvents m_inboxItems As Items 'All Outlook inbox items

Private WithEvents m_calendarItems As Items 'All Outlook calendar items

Private m_outlookInstalled As Boolean = False 'indicates whether Outlook is installed on computer

Private m_emails As New List(Of OutlookInboxEmail) 'used to store inbox e-mail messages for grid view control

Private m_inboxFolder As MAPIFolder 'Outlook inbox folder

Private m_calendarFolder As MAPIFolder 'Outlook calendar

Private m_explorer As Explorer 'Outlook window explorer

Private m_name As String = String.Empty 'the name user who is connected

Public Sub New()

InitializeComponent()

connectToOutlook()

loadInbox()

End Sub

Private Sub connectToOutlook()

m_outlookApplication = New Microsoft.Office.Interop.Outlook.Application

m_nameSpace = m_outlookApplication.GetNamespace("MAPI")

m_nameSpace.Logon(Missing.Value, Missing.Value, False, True)

Dim connectionMode = m_nameSpace.ExchangeConnectionMode

End Sub

Private Sub loadInbox()

Try

'get inbox folder

m_inboxFolder = m_nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox)

'get inbox messages

m_inboxItems = m_inboxFolder.Items

m_emails.Clear()

'display recent messages first

m_inboxItems.Sort("ReceivedTime", True)

Dim numberOfEmailsToLoad As Integer = 30

'set displayed values for each message

For Each currentItem As Object In m_inboxItems

Dim emailItem = TryCast(currentItem, MailItem)

If Not emailItem Is Nothing Then

'check whether its e-mail

If emailItem.MessageClass = "IPM.Note" Then

'set email

Dim inboxEmail As New OutlookInboxEmail

inboxEmail.SenderName = emailItem.SenderName

inboxEmail.Subject = emailItem.Subject

inboxEmail.ReceivedTime = emailItem.ReceivedTime.ToString("dd MMMM HH:mm")

inboxEmail.Body = emailItem.Body

inboxEmail.Unread = emailItem.UnRead

inboxEmail.Email = emailItem

m_emails.Add(inboxEmail)

numberOfEmailsToLoad = numberOfEmailsToLoad - 1

If numberOfEmailsToLoad <= 0 Then

Exit For

End If

End If

End If

Next

If m_explorer Is Nothing Then

Try

m_explorer = m_outlookApplication.ActiveExplorer

Catch ex As System.Exception

End Try

End If

If GridControl1.DataSource Is Nothing Then

GridControl1.DataSource = Nothing

GridControl1.DataSource = m_emails

End If

GridControl1.RefreshDataSource()

Catch exception As System.Exception

End Try

End Sub

'''

''' Opens email in Outlook

'''

'''

Private Sub openEmail()

If Not GridView1.GetFocusedDataSourceRowIndex < 0 Then

Dim selectedEmail = TryCast(m_emails(GridView1.GetFocusedDataSourceRowIndex), OutlookInboxEmail)

If Not selectedEmail Is Nothing Then

Try

If Process.GetProcessesByName("OUTLOOK").Count() = 0 Then

End If

selectedEmail.Email.Display()

selectedEmail.Unread = False

selectedEmail.EmailImage = My.Resources.Read_16

Catch exception As COMException

End Try

GridControl1.RefreshDataSource()

End If

End If

End Sub

Private Sub GridControlCalendar_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridControl1.DoubleClick

openEmail()

End Sub

End Class

2013-10-07

Chris

+0

如果您看到任务栏图标消失,则例外是预期结果。没有任何暗示为什么它决定退出。在Windows应用程序日志中查找面包屑。 –

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值