VBA code to send email from Secondary email address in Outlook

假装没事ソ 提交于 2020-01-05 13:58:11

问题


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.

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.

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.

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?


回答1:


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/

oMail.SentOnBehalfOfName = "user@domain.com"


来源:https://stackoverflow.com/questions/26427302/vba-code-to-send-email-from-secondary-email-address-in-outlook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!