开发者

how to get email address from messages in outlook 2003

Sub GetALLEmailAddresses()

Dim objFolder As Folders
Set objFolder = Application.ActiveExplorer.Selection



Dim dic As New Dictionary
Dim strEmail As String
Dim strEmails As String

Dim objItem As MailItem
For 开发者_开发百科Each objItem In objFolder.Items

strEmail = objItem.SenderEmailAddress
If Not dic.Exists(strEmail) Then
strEmails = strEmails + strEmail + ";"
dic.Add strEmail, ""
End If

Next

Debug.Print strEmails
End Sub

I use this code to get email address from message body. I'm not prefect in vb. is there any to help how to get email address from messages in outlook 2003?


In that case, I don't think there's anything built in, so I'd suggest that you don't bother with the SenderEmailAddress but instead just get out the Body and then search the text for email addresses. This will get somewhat complicated though since it might be difficult to be able to tell what's part of an email address and what isn't.

The easiest place to start with is to just look for any @ in the text, and then search for the next whitespace on either side of the @ and get everything between those whitespaces. But there are a lot of issues to think about. What if the user typed @ for some other reason, or if the email contains something like The first email is xxx@test.com.The second email is xxx2@test.com (note the missing space between the . and the The), where your app might think that the email should be xxx@test.com.The.

Edited since my answer was based on a complete misunderstanding of the question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜