显示 mailitem 生成运行时错误 -2147467259
Displaying mailitem generates Runtime Error -2147467259
如果 conversationID 与请求相同,我会循环遍历 MailItem 集合以显示 MailItem。
但是,似乎,当搜索的项目不在 ActiveSelection 上并且调用 MailItem.Display 函数时,它会产生 'Runtime Error -2147467259'
Outlook can't do this because a dialog box is open. Please close it and try again.
这是代码
' email_link_Click() '
' -> Compares the ConversationID sent through to get the email '
Sub email_link_Click()
Dim searchFolder As Object
Set olNs = Application.GetNamespace("MAPI")
Set olFldr = olNs.GetDefaultFolder(olFolderInbox)
Set searchFolder = olFldr
If Not Me.email_folder.Caption = "Inbox" Then
Set searchFolder = olFldr.Folders(Me.email_folder.Caption)
End If
searchFolder.Items.Sort "[Subject]", False
For Each emailvar In searchFolder.Items
If emailvar.ConversationID = Me.conversationID_label.Caption Then
FilingPrint ("Found email - Opening..")
emailvar.Display '<- Error is created from here
Exit Sub
End If
Next emailvar
Set searchFolder = Nothing
End Sub
这是因为它不能同时查看两个电子邮件吗?
所以最后的问题是我实际上打开了 2 个视图实例。我没有在上面花太多时间,而是创建了一个看起来像电子邮件视图的用户表单,并从已解析的 MailItem 对象中提取详细信息。
如果 conversationID 与请求相同,我会循环遍历 MailItem 集合以显示 MailItem。
但是,似乎,当搜索的项目不在 ActiveSelection 上并且调用 MailItem.Display 函数时,它会产生 'Runtime Error -2147467259'
Outlook can't do this because a dialog box is open. Please close it and try again.
这是代码
' email_link_Click() '
' -> Compares the ConversationID sent through to get the email '
Sub email_link_Click()
Dim searchFolder As Object
Set olNs = Application.GetNamespace("MAPI")
Set olFldr = olNs.GetDefaultFolder(olFolderInbox)
Set searchFolder = olFldr
If Not Me.email_folder.Caption = "Inbox" Then
Set searchFolder = olFldr.Folders(Me.email_folder.Caption)
End If
searchFolder.Items.Sort "[Subject]", False
For Each emailvar In searchFolder.Items
If emailvar.ConversationID = Me.conversationID_label.Caption Then
FilingPrint ("Found email - Opening..")
emailvar.Display '<- Error is created from here
Exit Sub
End If
Next emailvar
Set searchFolder = Nothing
End Sub
这是因为它不能同时查看两个电子邮件吗?
所以最后的问题是我实际上打开了 2 个视图实例。我没有在上面花太多时间,而是创建了一个看起来像电子邮件视图的用户表单,并从已解析的 MailItem 对象中提取详细信息。