Syncronise Accesstable with Outlook-Folder

J

Jeff2003

I have the following problem.

I have written a procedure in VBA to connect me to
Outlook.
The problem is that he produces a Error when want to read
the senders adress.
--> 'MsgBox olMessage.Sender
--> 'MsgBox olMessage.Sender.Name

Here is my complete code:

Private Sub ReadMails(pFolder As String)

Dim olMAPI As MAPI.Session
Dim olInfoStore As MAPI.InfoStore
Dim olFoldersCol As MAPI.Folders
Dim olFolder As Folder
Dim olMessageCol As Messages
Dim olMessage As Message

Set olMAPI = New MAPI.Session
olMAPI.Logon ("test")

Set olInfoStore = olMAPI.GetInfoStore()
Set olFoldersCol = olInfoStore.RootFolder.Folders
With olFoldersCol
For Each olFolder In olFoldersCol
If olFolder.Name = pFolder Then
Set olMessageCol = olFolder.Messages
With olMessageCol
For Each olMessage In olMessageCol
MsgBox "ID: " & vbCrLf & olMessage.ID
--> 'MsgBox olMessage.Sender
--> 'MsgBox olMessage.Sender.Name
MsgBox olMessage.Text
MsgBox olMessage.Subject
MsgBox olMessage.Recipients(1).Name
Set olMessage = .GetNext
Next olMessage
End With
End If
Next olFolder
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top