【问题标题】:Identify Shared mailbox name识别共享邮箱名称
【发布时间】:2020-08-04 05:28:37
【问题描述】:

我有两个邮箱,每次使用 Reply Action 时,我都想要一个 message box 来识别邮箱。

Option Explicit
Dim WithEvents AVDEMAL As Outlook.Folder
Dim avdEMAILmoved As Outlook.Folder
Dim avdEMAILolns As Outlook.NameSpace

Private Sub Application_Startup()
Set avdolns = Application.GetNamespace("MAPI")
Set AVDAVDEMAIL = avdAVDEMAILolns.Folders("AVDAVDEMAIL").Folders("Inbox")
end sub

Private Sub oItem_Reply(ByVal Response As Object, Cancel As Boolean)
If Application.GetNamespace("MAPI") = "AVDAVDEMAIL" Then
    MsgBox " hello , You are using AVD-EMAIL"
end if
end sub

当我运行代码时,它没有错误但没有显示消息框。

【问题讨论】:

    标签: vba outlook


    【解决方案1】:

    我已经知道了。

    供其他人参考,这是解决方案。只需添加以下代码即可。

    Option Explicit
    Private WithEvents oItem As MailItem
    Private Sub oItem_Reply(ByVal Response As Object, Cancel As Boolean)
    MsgBox (oItem.Parent.store)
    

    有效! :)

    【讨论】:

    • 你确定这行得通吗? oItem.Parent.store 返回一个 Store 对象。我希望您需要:oItem.Parent.Store.Name.
    • 是的。我只是用这个完成我的代码。 :) 如果您要添加 .name,它将只显示主邮箱,并且不适用于共享邮箱
    • 我只能假设.NameStore 的默认属性,这就解释了为什么你可以省略它。我不明白为什么它不适用于共享邮箱。我退休了,不再可以访问共享邮箱,但是当我这样做时,适用于私人邮箱的代码也适用于共享。它有效,这是主要的;为什么不那么重要。
    猜你喜欢
    • 2016-06-15
    • 2019-12-19
    • 1970-01-01
    • 1970-01-01
    • 2019-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多