当没有帐户可用时,Outlook VBA .SendUsingAccount

问题描述 投票:0回答:2

故事:在Outlook App中,有一个默认/用户帐户,还有其他收件箱,日历(让我们称之为2nd_Account)等,根据Exchange Server权限添加(可见)为文件夹。

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

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

谢谢

vba outlook outlook-vba outlook-2010
2个回答
0
投票

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


0
投票

以下是我浏览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
© www.soinside.com 2019 - 2024. All rights reserved.