通过MS Access VBA/Outlook发送电子邮件,选择发送配置文件 [英] Sending email through MS Access VBA / Outlook, choosing sending profile
问题描述
我正在从此处的另一个问题(MS Access VBA)看这段代码: https://stackoverflow.com/a /17975507/1085885
I am looking at this snippet of code from another question here (MS Access VBA): https://stackoverflow.com/a/17975507/1085885
现在,此代码仅在打开Outlook的情况下运行时才有效.此代码有什么办法可以打开Outlook",然后运行所有发送代码?
Right now this code only works when I run it while Outlook is open. Is there any way for this code to "open Outlook" and then run all the sending code?
第二,如何选择要发送的Outlook配置文件?我可以访问几个不同的配置文件,并且该配置文件是从我的主要顶部收件箱发送的,但我希望它来自第二个收件箱.
Secondly, how can I choose which Outlook profile to send from? I have access to a couple different profiles and it's sending from my main top inbox but I want it to come from my second inbox.
推荐答案
您需要登录到指定的配置文件.创建Outlook应用程序实例后
You need to log to the specified profile. After creating an instance of the Outlook application
Set oApp = CreateObject("Outlook.application")
添加如下内容:
set oNS = oApp.GetNamespace.Logon
oNS.Logon("MyProfileName")
请注意,如果Outlook已经在运行,则登录将不执行任何操作.您将需要使用扩展MAPI(C ++或Delphi或MAPI包装器,例如兑换( RDOSession .Logon)登录到指定的个人资料.
Note if Outlook is already running, Logon will do nothing. You will need to use Extended MAPI (C++ or Delphi or a MAPI wrapper like Redemption (RDOSession.Logon) to log to a specified profile.
为什么不使用单个配置文件并创建多个提示?然后,您可以设置MailItem.SendUsaingAccount
属性以指定特定帐户.
Why not work with a single profile and create multiple accpunts? You can then set the MailItem.SendUsaingAccount
property to specify a particular account.
这篇关于通过MS Access VBA/Outlook发送电子邮件,选择发送配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!