Jesse
Microsoft Outlook - capturing email address
Started by
CypressTech
, Jun 09 2005 10:16 AM
#1
Posted 09 June 2005 - 10:16 AM
Jesse
#2
Posted 11 June 2005 - 12:26 AM
#3
Posted 11 June 2005 - 04:00 AM
This outlook macro will get the email address of the sender and the display names of the receivers from a folder that you select.
I hope this helps. I have just started learning about macros in outlook. This worked for me in Outlook 2003.
Sub GetDisplayNames()
Set oApp = CreateObject("Outlook.Application")
Set oNS = oApp.GetNamespace("MAPI")
'Set oFolder = oNS.GetDefaultFolder(olFolderSentMail)
Set oFolder = oNS.PickFolder
Set oItems = oFolder.Items
Debug.Print "I am checking folder - ", oFolder.Name
Debug.Print "Count of messages in this folder - ", oItems.Count
'Get unread e-mail messages.
'oItems = oItems.Restrict("[Unread] = true")
'Console.WriteLine ("Total Unread : " & oItems.Count)
'Loop through each message.
Dim oMsg As Outlook.MailItem
Dim i As Integer
For i = 1 To oItems.Count
Set oMsg = oItems.Item(i)
Debug.Print (i),
'Debug.Print (oMsg.SenderName)
Debug.Print "Sender >> ", (oMsg.SenderEmailAddress)
Debug.Print , "Receiver >> ", (oMsg.To)
'Debug.Print (oMsg.Subject)
'Debug.Print (oMsg.ReceivedTime)
'Debug.Print (oMsg.Body)
Debug.Print ("---------------------------")
Next
'Clean up.
Set oApp = Nothing
Set oNS = Nothing
Set oFolder = Nothing
Set oItems = Nothing
Set oMsg = Nothing
End Sub
I hope this helps. I have just started learning about macros in outlook. This worked for me in Outlook 2003.
Sub GetDisplayNames()
Set oApp = CreateObject("Outlook.Application")
Set oNS = oApp.GetNamespace("MAPI")
'Set oFolder = oNS.GetDefaultFolder(olFolderSentMail)
Set oFolder = oNS.PickFolder
Set oItems = oFolder.Items
Debug.Print "I am checking folder - ", oFolder.Name
Debug.Print "Count of messages in this folder - ", oItems.Count
'Get unread e-mail messages.
'oItems = oItems.Restrict("[Unread] = true")
'Console.WriteLine ("Total Unread : " & oItems.Count)
'Loop through each message.
Dim oMsg As Outlook.MailItem
Dim i As Integer
For i = 1 To oItems.Count
Set oMsg = oItems.Item(i)
Debug.Print (i),
'Debug.Print (oMsg.SenderName)
Debug.Print "Sender >> ", (oMsg.SenderEmailAddress)
Debug.Print , "Receiver >> ", (oMsg.To)
'Debug.Print (oMsg.Subject)
'Debug.Print (oMsg.ReceivedTime)
'Debug.Print (oMsg.Body)
Debug.Print ("---------------------------")
Next
'Clean up.
Set oApp = Nothing
Set oNS = Nothing
Set oFolder = Nothing
Set oItems = Nothing
Set oMsg = Nothing
End Sub
Similar Topics
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users