General discussion

Locked

How to read an Exchange Mbx, MAPI, VB 6

By eedwards ·
I am looking for detailed examples of using MAPI. The primary method I need would read an Exchange Mailbox or sub-folder using the MAPI object within Visual Basic 6. I might also have to then write email using MAPI. Any sample code would be appriciated. I have found lots of general talk but no samples.

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

How to read an Exchange Mbx, MAPI, VB 6

by dale.johnson In reply to How to read an Exchange M ...

There is a sample program that should be installed when VB 6 is installed. It should be located at:
"C:\Program Files\Microsoft Visual Studio\MSDN98\98VSa\1033\SAMPLES\VB98\misc\Vbmail"

This is a very simple application and a very good start. If you do not have this sample, please contact me and I will email it to you.

Dale

Collapse -

How to read an Exchange Mbx, MAPI, VB 6

by eedwards In reply to How to read an Exchange M ...

Poster rated this answer

Collapse -

How to read an Exchange Mbx, MAPI, VB 6

by RRV In reply to How to read an Exchange M ...

This function which i have written in VB6 opens the current windows NT user's email user login in MS exchange server and fetches the address book.
rrv@hotvoice.com
Raja venkatesh R


Function LoadMailIds() As Boolean
On Error GoTo ErrHndl
DimobjSession As MAPI.Session
Dim objAddrEntries As AddressEntries
Dim objAddressEntry As AddressEntry
Dim objFilter As AddressEntryFilter
Dim strProfileInfo As String
Dim NxtMailItem As Long
Dim strMailBox As String
Dim ProfPath As String
Dim strServer As String
ProfPath = "Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
Call GetKeyValue(HKEY_CURRENT_USER, ProfPath, "DefaultProfile", strServer)
ProfPath = "Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\" & strServer & "\13dbb0c8aa05101a9bb000aa002fc45a"
Call GetKeyValue(HKEY_CURRENT_USER, ProfPath, "001e3001", strMailBox)
strProfileInfo = strServer & vbLf & strMailBox
Set objSession = CreateObject("MAPI.Session")
objSession.Logon , , False, False, , True, strProfileInfo
'open Global address book
Set objAddrEntries = objSession.AddressLists("Global Address Book").AddressEntries
'or open personal address book
Set objAddrEntries = objSession.AddressLists("Personal Address Book").AddressEntries
'MailCCLst is a list box in form frmMail
frmMail.MailCCLst.Clear
NxtMailItem = 0
For Each objAddressEntry In objAddrEntries
NxtMailItem = NxtMailItem + 1
Next
ReDim MailAddressArray(NxtMailItem - 1, 1)
Cnt = 0
For Each objAddressEntry In objAddrEntries
frmMail.MailCCLst.AddItem objAddressEntry.Name
MailAddressArray(Cnt, 0) = objAddressEntry.Name
MailAddressArray(Cnt, 1) = objAddressEntry.Address
Cnt = Cnt + 1
Next
objSession.Logoff
Set objAddrEntries = Nothing
Set objSession = Nothing
LoadMailIds = True
Exit Function
ErrHndl:
LoadMailIds = False
End Function

Collapse -

How to read an Exchange Mbx, MAPI, VB 6

by eedwards In reply to How to read an Exchange M ...

Poster rated this answer

Collapse -

How to read an Exchange Mbx, MAPI, VB 6

by RRV In reply to How to read an Exchange M ...

This function which i have written in VB6 opens the current windows NT user's email user login in MS exchange server and fetches the address book.
rrv@hotvoice.com
Raja venkatesh R


Function LoadMailIds() As Boolean
On Error GoTo ErrHndl
DimobjSession As MAPI.Session
Dim objAddrEntries As AddressEntries
Dim objAddressEntry As AddressEntry
Dim objFilter As AddressEntryFilter
Dim strProfileInfo As String
Dim NxtMailItem As Long
Dim strMailBox As String
Dim ProfPath As String
Dim strServer As String
ProfPath = "Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
Call GetKeyValue(HKEY_CURRENT_USER, ProfPath, "DefaultProfile", strServer)
ProfPath = "Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\" & strServer & "\13dbb0c8aa05101a9bb000aa002fc45a"
Call GetKeyValue(HKEY_CURRENT_USER, ProfPath, "001e3001", strMailBox)
strProfileInfo = strServer & vbLf & strMailBox
Set objSession = CreateObject("MAPI.Session")
objSession.Logon , , False, False, , True, strProfileInfo
'open Global address book
Set objAddrEntries = objSession.AddressLists("Global Address Book").AddressEntries
'or open personal address book
Set objAddrEntries = objSession.AddressLists("Personal Address Book").AddressEntries
'MailCCLst is a list box in form frmMail
frmMail.MailCCLst.Clear
NxtMailItem = 0
For Each objAddressEntry In objAddrEntries
NxtMailItem = NxtMailItem + 1
Next
ReDim MailAddressArray(NxtMailItem - 1, 1)
Cnt = 0
For Each objAddressEntry In objAddrEntries
frmMail.MailCCLst.AddItem objAddressEntry.Name
MailAddressArray(Cnt, 0) = objAddressEntry.Name
MailAddressArray(Cnt, 1) = objAddressEntry.Address
Cnt = Cnt + 1
Next
objSession.Logoff
Set objAddrEntries = Nothing
Set objSession = Nothing
LoadMailIds = True
Exit Function
ErrHndl:
LoadMailIds = False
End Function

Collapse -

How to read an Exchange Mbx, MAPI, VB 6

by eedwards In reply to How to read an Exchange M ...

Submitted twice. I accepted the first answer.
Thank you

Collapse -

How to read an Exchange Mbx, MAPI, VB 6

by eedwards In reply to How to read an Exchange M ...

This question was closed by the author

Back to Web Development Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums