How to send email in Outlook on behalf of a Delegate?

不羁岁月 提交于 2019-12-04 02:04:13

问题


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.

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)


回答1:


Check out the MailItem.SentOnBehalfOfName Property. You should have delegate access to the mailbox/profile on whose behalf you want to send.

Example:

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

The email would say From Jimmy Pena on behalf of Jimmy's Boss in the From: field.



来源:https://stackoverflow.com/questions/11513869/how-to-send-email-in-outlook-on-behalf-of-a-delegate

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