Re: Reading Outlook Mailbox
Hi,
I don't know if it is of any help.
Hi,
I don't know if it is of any help.
Code:
[SIZE=4]'Date Created: 28-Apr-2006 02:55:43 AM [/SIZE][SIZE=3]'Last Updated: 26-Jun-2010 08:43:44 PM 'Created By : Jeff Kletrovets 'Updated By : Marcel Kollenaar 'Four years later ...[/SIZE] [SIZE=2] 'I did some further investigation for accessing the Outlook Inbox, in my case Outlook 2003.[/SIZE] [SIZE=4] 'There is a sub folder "NetGearLogs" in the Inbox that I want to acccess and process all the email in it. 'It has data like:[/SIZE] [SIZE=2] '... '[Service blocked: ICMP_echo_req] from source 115.30.222.24, Thursday, Jun 17,2010 13:02:41 '[DOS attack: FIN Scan] attack packets in last 20 sec from ip [74.125.79.136], Thursday, Jun 17,2010 11:52:42 '[DOS attack: FIN Scan] attack packets in last 20 sec from ip [74.125.79.104], Thursday, Jun 17,2010 11:52:37 '[DOS attack: FIN Scan] attack packets in last 20 sec from ip [74.125.79.93], Thursday, Jun 17,2010 11:52:34 '[DOS attack: FIN Scan] attack packets in last 20 sec from ip [74.125.79.147], Thursday, Jun 17,2010 11:52:30 '[DOS attack: FIN Scan] attack packets in last 20 sec from ip [74.125.79.91], Thursday, Jun 17,2010 11:50:57 '... 'and want to do some statistics on the data, up to 2 years back.[/SIZE] [SIZE=2] dim connString as C[/SIZE] [SIZE=2] dim conn as ole::adodb.connection connString="Provider=Microsoft.JET.OLEDB.4.0;Exchange 4.0;MAPILEVEL=[COLOR=Red]Persoonlijke mappen|Postvak IN[/COLOR];PROFILE=Outlook;TABLETYPE=0;DATABASE=C:\temp\;" 'Found some additiona information on http://www.vbforums.com/archive/index.php/t-431916.html[/SIZE] [SIZE=2] 'The connection string they give is: "Exchange 4.0;MAPILEVEL= storage|folderpath;TABLETYPE={0|1}; DATABASE=path;[PROFILE=profile;PWD=password;]" [/SIZE] [SIZE=2] 'with parameters:[/SIZE] [SIZE=2] 'Element Description 'Identifier: Exchange 4.0 (required). The setting works with Microsoft Exchange 4.x, 5.0, and Outlook data. 'Source table path[/SIZE] [SIZE=2] 'TABLETYPE=0 (for folders) (default)TABLETYPE=1 (for address books; required) 'MAPILEVEL=storage|folderpath (required). The storage entry is the exact name[/SIZE] [SIZE=2] ' of a mailbox on a server, a personal folder, or public folder as it appears ' in the Outlook Folder List; and folderpath is the path to the folder immediately ' above the folder you want to connect to. The storage entry and the pipe character ' (|) are always required. The folders entry is required to access folders below ' the top-level of folders within storage. When you are listing nested folders, ' separate each folder name with a backslash (\) (for example, "Mailbox � Pat Smith|Inbox\Big Project"). 'Database name[/SIZE] [SIZE=2] 'DATABASE=path (required). The path entry is the fully resolved path and file name to a ' Microsoft Access database (.mdb) in which to store system tables used by the driver ' (usually the current database). ' For Outlook it creates a schema.ini file in the c:\temp\ folderwith the fieldnames like the schema below. ' ' [1 - Exchange - NetGearLogs] ' IdSize=24 ' IdBytes=00 00 00 00 30 2B 65 BE 4D 4A 0E 46 B0 11 82 41 F0 83 A6 E5 02 41 02 00 ' Col1=Urgentie Integer ' Col2=Berichtklasse Char Width 510 ' Col3=Prioriteit Integer ' Col4=Onderwerp Char Width 510 ' Col5=Afzender Char Width 510 ' Col6="Bericht aan mijzelf" Bit ' Col7="CC van bericht aan mijzelf" Bit ' Col8="Naam afzender" Char Width 510 ' Col9=CC Char Width 510 ' Col10=Aan Char Width 510 ' Col11=Ontvangen DateTime ' Col12=Berichtgrootte Integer ' Col13=Hoofdtekst LongChar ' Col14=Aanmaaktijd DateTime ' Col15="Laatst gewijzigd" DateTime ' Col16="Voorvoegsel onderwerp" Char Width 510 ' Col17="Met bijlagen" Bit ' Col18="Genormaliseerd onderwerp" Char Width 510 ' Col19=Objecttype Integer ' Col20="Inhoud ongelezen" Integer 'Profile name[/SIZE] [SIZE=2] 'PROFILE=profile (optional; if not specified, the default profile is used). ' The profile entry is the name of the Microsoft Exchange or Outlook profile to use. 'Password[/SIZE] [SIZE=2] 'PWD=password (optional; not required if your network logon password is passed to your ' Microsoft Exchange server). The password entry is the Microsoft Exchange or Outlook logon password. conn.open(connString)[/SIZE] [SIZE=2] 'Reminder! Use the folder names in your own language below![/SIZE] [SIZE=2] 'rs=conn.Execute("select * from Agenda") 'OK! 'rs=conn.Execute("select * from Contactpersonen") 'OK! 'rs=conn.Execute("select * from postvak in") 'Fault 'rs=conn.Execute("select * from postvak_in") 'Fault 'rs=conn.Execute("select * from [postvak in]") 'OK! rs=conn.Execute("select * from [COLOR=Red]NetGearLogs[/COLOR]") 'OK! - to select subfolders change MAPILEVEL=Persoonlijke mappen|Postvak IN msgbox("", str(rs.fields.count()))[/SIZE] [SIZE=2] ' display who message is from and subject line[/SIZE] [SIZE=4] dim MessageList as c = ""[/SIZE] [SIZE=2] while .not. rs.Eof()[/SIZE] [SIZE=2] MessageList = MessageList + rs.fields.item(4).value +" "+rs.fields.item(3).value + crlf() rs.MoveNext() end while ui_msg_box("Email Subject",MessageList)[/SIZE] [SIZE=2] rs.close()[/SIZE] [SIZE=2] conn.close()[/SIZE]
Comment