【问题标题】:How to hide sender email id while sending email by CDO in excel vba如何在excel vba中通过CDO发送电子邮件时隐藏发件人电子邮件ID
【发布时间】:2016-01-05 23:12:02
【问题描述】:

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

以下是我通过 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

【问题讨论】:

    标签: excel outlook smtp cdo.message vba


    【解决方案1】:

    尝试根据地址簿解析收件人。然后您将看到姓名而不是电子邮件地址。 Recipients 类的 ResolveAll 方法(请参阅 MailItem 类的对应属性)尝试根据通讯簿解析 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
    

    【讨论】:

    • 给出编译错误未定义用户定义类型并突出显示下面的代码。 Dim MyItem As Outlook.MailItem
    • 示例代码中使用了 Outlook 对象模型。
    • 但我使用的是 excel 宏,这些对象属于 Outlook。 excel vba中是否有任何方法可以根据地址簿解析收件人?
    • 感谢您的所有贡献,但我得到了答案,仅隐藏发件人 ID 非常简单。我只需要在我的代码中的姓名和 ID 之间使用逗号 (,),然后当我使用此技巧 From = """username"",&lt;email@abc.com&gt;" 时,收件人无法在他的屏幕上看到我的发件人地址,但发件人姓名除外。 :)
    猜你喜欢
    • 2016-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-03
    • 2016-03-10
    • 1970-01-01
    • 2017-02-08
    • 1970-01-01
    相关资源
    最近更新 更多