如何在Outlook中代表代理发送电子邮件? [英] How to send email in Outlook on behalf of a Delegate?
问题描述
我正在编写一个VBA脚本,该脚本将向我们的客户发送电子邮件.我以前使用过类似的系统,但是区别在于这些电子邮件将使用通用的发件人字段(因此收件人只会看到我们公司的名称,而不会看到发送它的个人).这很容易手动完成.
I'm writing a VBA script that will fire off emails to our customers. I've made similar systems before, but the difference here is that these emails will use a generic From field (so the recipient only sees our company's name and not the individual sending it). This is easy to do manually.
目前,我正在使用具有通用示例.但是我无法弄清楚如何使用该代码,因为它本身并不是这台计算机上的实际帐户.我只是可以访问它.
Currently, I'm playing around with the SendUsingAccount with generic examples. But I can't figure out how to use that code since it's not an actual account on this machine per se. I just have delegate access to it.
那么,有人可以告诉我如何使用VBA代表其他人发送电子邮件吗?
So, can someone show me how to send email on behalf of someone else using VBA?
(或者,我确实有该帐户的用户名和密码.因此,如果我需要登录该帐户以发送电子邮件,我也可以这样做)
(Alternatively, I do have the username and password to the account. So, if I need to log into that account to send the email, I can do that too)
推荐答案
Check out the MailItem.SentOnBehalfOfName Property. You should have delegate access to the mailbox/profile on whose behalf you want to send.
Sub SendEmailOnBehalf()
Dim msg As Outlook.MailItem
Set msg = Outlook.CreateItem(olMailItem)
With msg
.SentOnBehalfOfName = "Jimmy's boss' name"
.Subject = "Email from someone else"
.Body = "Hello" & vbNewLine
End With
End Sub
电子邮件在From:
字段中显示From Jimmy Pena on behalf of Jimmy's Boss
.
The email would say From Jimmy Pena on behalf of Jimmy's Boss
in the From:
field.
这篇关于如何在Outlook中代表代理发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!