【问题标题】:Outlook VBA .SendUsingAccount when no account is available没有可用帐户时的 Outlook VBA .SendUsingAccount
【发布时间】:2019-02-08 14:06:28
【问题描述】:

故事: 在 Outlook 应用程序中,有一个默认/用户帐户以及其他收件箱、日历(我们称之为 2nd_Account)等添加(可见)为基于 Exchange Server 权限的文件夹。

我需要以编程方式创建新的约会项目并代表 2nd_Account 发送。问题是 Application.Session 只有 1 个帐户(默认帐户)。

如果由用户手动完成,则从 2nd_Account olCalendar 文件夹创建的项目是 2nd_Account 的 SendOnBehalf,即使它不包含在 Accounts 集合中。请问有什么想法吗?

谢谢

【问题讨论】:

    标签: vba outlook outlook-2010


    【解决方案1】:

    在该帐户的日历文件夹中创建约会 - 使用 Store.GetDefaultFolder 而不是 Namespace.GetDefaultFolder

    【讨论】:

    • 实际上通过遍历文件夹集合NameSpace.Folders并将所需文件夹分配给变量并使用Application.CreateItemFromTemplate(strPath, olFolder)来解决
    【解决方案2】:

    以下是我在 Outlook 中浏览已安装帐户的方式:

    Set MAPISession = objOutlook.Application.Session     'Get the MAPI Outlook session
    Dim WantedAccount as String ' Set to preferred account name
    
    Set MAPIMailItem = objOutlook.CreateItem(olMailItem)  'Create a new mail message
    With MAPIMailItem
      For Each Account In MAPISession.Accounts
        If Account = WantedAccount Then
          .SendUsingAccount = Account
          Exit For
        End If
      Next
    

    【讨论】:

    • 谢谢,但关键是只有一个帐户可用(已安装),而文件夹(收件箱、已发送、日历)基于 Exchange Server 权限可供用户使用,因此在 Outlook 中可见。实际上通过遍历文件夹集合 NameSpace.Folders 并将所需文件夹分配给变量并使用 Application.CreateItemFromTemplate(strPath, olFolder) 解决了
    猜你喜欢
    • 2016-10-12
    • 1970-01-01
    • 2020-09-03
    • 1970-01-01
    • 2011-11-28
    • 2014-09-03
    • 2018-12-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多