Connecting Outlook (Original reply by Travis) (1 Viewer)

simongallop

Registered User.
Local time
Today, 17:17
Joined
Oct 17, 2000
Messages
611
A year ago Travis posted some code to connect to Outlook. I was wondering if anybody knows how to amend it to view a specific Mail account. The reason that I ask is that I want to have a mail account setup purely for an Access DB to read, called "Autoread". How would I put it into the following code?

Sub LinkExchangeFolder()
Dim dbs As Database, tdf As TableDef, str As String
Const conTableExists = 3012
On Error GoTo ErrorHandler
Set dbs = CurrentDb
str = "Exchange 4.0;MAPILEVEL=Personal Folders|;" _
& "TABLETYPE=0;" _
& "DATABASE=" & dbs.Name & ";" _
& "Profile=Microsoft OutLook;PWD= ;"
Set tdf = dbs.CreateTableDef("tblInbox")
tdf.Connect = str
tdf.SourceTableName = "Inbox" 'Change this to the Folder you are trying to look in
dbs.TableDefs.Append tdf
RefreshDatabaseWindow
link_exit:
dbs.Close
Set dbs = Nothing
Exit Sub
ErrorHandler:
If Err = conTableExists Then
MsgBox "The table you are trying to create already exists."
Resume link_exit
Else
MsgBox "Error: " & Err.Number & ": " & Err.Description
End If
End Sub

Thanks in advance

Simon
 

Users who are viewing this thread

Top Bottom