2016-07-12 36 views
0

有沒有辦法我可以使用以下命令MsgBox(mail.To)在onitemsend使用僅返回電子郵件地址和友好/別名?我需要單獨的電子郵件地址作爲用於我們的CRM的SQL查詢。目前,如果我使用MSGBOX(mail.To)我得到:MsgBox(mail.To)電子郵件地址只是不友好的名稱

李四([email protected]) 但我想: [email protected]

我相信這樣做是因爲Outlook在我的地址簿中查找電子郵件,因爲有一個無法幫助的條目。

非常感謝

+1

你的郵件對象是什麼類型的? – NePh

回答

0

試試這個:

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) 
+0

如果MailItem.Recipients集合具有顯式公開名稱和地址屬性的收件人對象,那麼完全沒有理由這麼做。 –

+0

我不知道MailItem.Recipients存在。感謝您的信息 :) – BanForFun

0

通過所有收件人使用MailItem.Recipients收集和循環。使用Recipient.Address/Name/Type屬性。

0
Dim mail As New MailMessage() 
mail = New MailMessage() 
mail.From = New MailAddress("[email protected]", "Your Firends Name") 

也許?

相關問題