如何从Outlook中的“To”字段中提取电子邮件地址? [英] How do you extract email addresses from the 'To' field in outlook?
问题描述
我一直在使用VBA,使用这段代码:
I have been using VBA to some degree, using this code:
Sub ExtractEmail()
Dim OlApp As Outlook.Application
Dim Mailobject As Object
Dim Email As String
Dim NS As NameSpace
Dim Folder As MAPIFolder
Set OlApp = CreateObject("Outlook.Application")
' Setup Namespace
Set NS = ThisOutlookSession.Session
' Display select folder dialog
Set Folder = NS.PickFolder
' Create Text File
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("c:\mydocuments\emailss.txt", True)
' loop to read email address from mail items.
For Each Mailobject In Folder.Items
Email = Mailobject.To
a.WriteLine (Email)
Next
Set OlApp = Nothing
Set Mailobject = Nothing
a.Close
End Sub
然而,这给出输出作为名称的电子邮件地址,而不是具有 something@this.domain
的实际电子邮件地址。
However this gives output as the names of the email addresses and not the actual email address with the "something@this.domain"
.
是否有一个mailobject的属性将允许电子邮件地址,而不是从 'To'
Is there an attributte of the mailobject that will allow the email addresses and not the names to be written from the 'To'
Textbox.
谢谢
推荐答案
查看收件人集合对象您的邮件项目,应允许您获取地址: http:// msdn.microsoft.com/en-us/library/office/ff868695.aspx
Check out the Recipients collection object for your mail item, which should allow you to get the address: http://msdn.microsoft.com/en-us/library/office/ff868695.aspx
这篇关于如何从Outlook中的“To”字段中提取电子邮件地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!