Created
May 31, 2010 15:21
-
-
Save umitanuki/419930 to your computer and use it in GitHub Desktop.
extract mail information from outlook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Const olFolderInbox = 6 | |
Const ForWriting = 2 | |
Const MessageID = 1709179138 | |
Const PR_INTERNET_MESSAGE_ID = &H1035001E | |
Set fs = WScript.CreateObject("Scripting.FileSystemObject") | |
Set ofile = fs.OpenTextFile("c:\tmp\mail.tsv", ForWriting) | |
Set ol = WScript.CreateObject("Outlook.Application") | |
Set myNameSpace = ol.GetNameSpace("MAPI") | |
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox) | |
Set myItems = myFolder.Items | |
'WScript.echo myItems.Count | |
'Dim mapiSession As New MAPI.Session | |
'Dim mapiMessage As MAPI.Message | |
Set mapiSession = WScript.CreateObject("MAPI.Session") | |
mapiSession.Logon "", "", False, False, True | |
For a = 1 To myItems.Count Step 1 | |
On Error Resume Next | |
Set item = myItems.Item(a) | |
' WScript.Echo item.Subject | |
Set mapiMessage = mapiSession.GetMessage(item.EntryID, item.Parent.StoreID) | |
' WScript.Echo mapiMessage.Fields(PR_INTERNET_MESSAGE_ID ).Value | |
ofile.Writeline item.Subject & chr(9) & item.ReceivedTime & chr(9) & item.SenderName & chr(9) & item.To & chr(9) & item.CC & chr(9) & item.BCC & chr(9) & item.senderEMailAddress & chr(9) & item.EntryID & chr(9) & mapiMessage.Fields(PR_INTERNET_MESSAGE_ID).Value | |
Next | |
ofile.Close | |
Set ol = Nothing | |
Set ofile = Nothing | |
Set fs = Nothing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment