【问题标题】:How can I create email message with address name?如何创建带有地址名称的电子邮件?
【发布时间】:2017-12-12 19:47:03
【问题描述】:

我按照以下示例进行操作。

https://www.slipstick.com/developer/create-a-new-message-using-vba/

我想在自动制作电子邮件草稿时显示通讯簿名称。

例如,在这种情况下,

我可以在地址字段中显示“BZ@gmail.com”,但我想显示地址簿的名称“业务团队”,因为“业务团队”更容易看到。

这是我的代码。与示例代码几乎相同。

Public Sub CreateNewMessage()
Dim objMsg As MailItem

Set objMsg = Application.CreateItem(olMailItem)

With objMsg
  .To = "Alias@domain.com"
  .CC= "Alias2@domain.com"
  .BCC = "Alias3@domain.com"
  .Subject = "This is the subject"
  .Categories = "Test"
  .VotingOptions = "Yes;No;Maybe;"
  .BodyFormat = olFormatPlain ' send plain text message
  .Importance = olImportanceHigh
  .Sensitivity = olConfidential
  .Attachments.Add ("path-to-file.docx")

 ' Calculate a date using DateAdd or enter an explicit date
  .ExpiryTime = DateAdd("m", 6, Now) '6 months from now
  .DeferredDeliveryTime = #8/1/2012 6:00:00 PM#

  .Display
End With

Set objMsg = Nothing
End Sub

我只能通过“alisas@domain.com”发送,当我看到打开的草稿时,会显示电子邮件地址。

如何在草稿中显示通讯录名称?

【问题讨论】:

  • 如果 Business Team 在 Exchange 环境下的 GAL 中,Outlook 会在一定时间后尝试解析名称。您的链接代码中没有MsgBox,那么您的代码是什么?通过编辑您的帖子添加您的代码。
  • 不要介意 msgbox...我只是说...我不想要使用 msgbox 的答案。在我的代码中没有 msgbox。
  • 我会上传我的代码,请稍等
  • 哇,你太棒了!
  • 谢谢...但是如何按地址名称添加抄送...?

标签: vba outlook


【解决方案1】:

关于您问题的第一部分,请参阅Recipients.Add Method (Outlook)

对于抄送,您需要更改收件人类型,请参阅此SO question 的答案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-17
    • 2017-11-12
    • 1970-01-01
    • 2012-10-12
    • 2011-06-28
    • 1970-01-01
    • 1970-01-01
    • 2016-07-21
    相关资源
    最近更新 更多