如何在excel vba中通过CDO发送电子邮件时隐藏发件人电子邮件ID

时间:2015-10-08 11:03:16

标签: excel-vba outlook smtp cdo.message vba

我想隐藏发件人电子邮件ID ,而不是隐藏收件人姓名,如下所示

enter image description here

以下是我通过 CDO

发送电子邮件的脚本的一部分
With iMsg
    Set .Configuration = iConf
    .To = "open.dealerz@gmail.com"
    .CC = ""
    .BCC = ""
    .From = "Dealer <open.dealerz@gmail.com>" 
    .Subject = "Test"
    .TextBody = ""
    .Send
End With

1 个答案:

答案 0 :(得分:1)

尝试根据地址簿解析收件人。然后,您将看到名称而不是电子邮件地址。 Recipients类的ResolveAll方法(请参阅MailItem类的corresposning属性)尝试根据通讯簿解析Recipients集合中的所有Recipient对象。

Sub CheckRecipients()  
 Dim MyItem As Outlook.MailItem  
 Dim myRecipients As Outlook.Recipients  
 Dim myRecipient As Outlook.Recipient 
 Set myItem = Application.CreateItem(olMailItem)  
 Set myRecipients = myItem.Recipients  
 myRecipients.Add("Aaron Con")  
 myRecipients.Add("Nate Sun")  
 myRecipients.Add("Dan Wilson")  
 If Not myRecipients.ResolveAll Then  
  For Each myRecipient In myRecipients  
   If Not myRecipient.Resolved Then  
    MsgBox myRecipient.Name 
   End If 
  Next  
 End If  
End Sub