有没有办法我可以使用以下命令MsgBox(mail.To)在onitemsend使用仅返回电子邮件地址和友好/别名?我需要单独的电子邮件地址作为用于我们的CRM的SQL查询。目前,如果我使用MSGBOX(mail.To)我得到:MsgBox(mail.To)电子邮件地址只是不友好的名称
李四([email protected]) 但我想: [email protected]
我相信这样做是因为Outlook在我的地址簿中查找电子邮件,因为有一个无法帮助的条目。
非常感谢
有没有办法我可以使用以下命令MsgBox(mail.To)在onitemsend使用仅返回电子邮件地址和友好/别名?我需要单独的电子邮件地址作为用于我们的CRM的SQL查询。目前,如果我使用MSGBOX(mail.To)我得到:MsgBox(mail.To)电子邮件地址只是不友好的名称
李四([email protected]) 但我想: [email protected]
我相信这样做是因为Outlook在我的地址簿中查找电子邮件,因为有一个无法帮助的条目。
非常感谢
试试这个:
Dim str As String = mail.To
Dim lst As String() = str.Split({" "}, StringSplitOptions.RemoveEmptyEntries)
Dim email As String = ""
For Each w1 In lst
If w1.Contains("@") Then
email = w1
End If
Next
email = email.Replace("(", "")
email = email.Replace(")", "")
MsgBox(email)
如果MailItem.Recipients集合具有显式公开名称和地址属性的收件人对象,那么完全没有理由这么做。 –
我不知道MailItem.Recipients存在。感谢您的信息 :) – BanForFun
通过所有收件人使用MailItem.Recipients
收集和循环。使用Recipient.Address
/Name
/Type
属性。
Dim mail As New MailMessage()
mail = New MailMessage()
mail.From = New MailAddress("[email protected]", "Your Firends Name")
也许?
你的邮件对象是什么类型的? – NePh