从 Outlook 中的辅助电子邮件地址发送电子邮件的 VBA 代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26427302/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VBA code to send email from Secondary email address in Outlook
提问by Mike Marshall
I am using Excel 2010 on W7 x64, and send email from Outlook using code from Ron de Bruin. I have an individual and group email address that I send from, and am looking for a way to send from the group address by changing it in VBA.
我在 W7 x64 上使用 Excel 2010,并使用 Ron de Bruin 的代码从 Outlook 发送电子邮件。我有一个发送的个人和组电子邮件地址,并且正在寻找一种通过在 VBA 中更改组地址来发送的方法。
The secondary address is not set up as an actual account in Outlook. If I go to File - Account Settings in Outlook, there is only one email account listed. The group email address simply forwards to the group.
辅助地址未设置为 Outlook 中的实际帐户。如果我转到 Outlook 中的文件 - 帐户设置,则只会列出一个电子邮件帐户。群组电子邮件地址只是转发给群组。
I created an actual account for the group box, and added the reference to Microsoft Outlook Object Library in VBA, and added the code to select between account 1 or 2 using the MailItem.SendUsingAccount property, but Outlook would freeze up when trying to send from this address.
我为分组框创建了一个实际帐户,并在 VBA 中添加了对 Microsoft Outlook 对象库的引用,并添加了使用 MailItem.SendUsingAccount 属性在帐户 1 或 2 之间进行选择的代码,但 Outlook 在尝试发送时会冻结这个地址。
I can select between my Individual and Group email in the from dropdown box in Outlook when I send emails. Is there another way to do this in VBA without setting up a second account?
发送电子邮件时,我可以在 Outlook 的“发件人”下拉框中选择“个人”和“组”电子邮件。在 VBA 中是否有另一种方法可以在不设置第二个帐户的情况下执行此操作?
回答by Paresh J
You can use .SentOnBehalfOfName property of outlook to send mail in the name of other user. Check the following code and URL for further details: http://www.slipstick.com/developer/code-samples/send-email-address-vba/
您可以使用 Outlook 的 .SentOnBehalfOfName 属性以其他用户的名义发送邮件。检查以下代码和 URL 以获取更多详细信息:http: //www.slipstick.com/developer/code-samples/send-email-address-vba/
oMail.SentOnBehalfOfName = "[email protected]"

