Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Using MAPI to read email

Hello,

I am trying to use Microsoft MAPI to read email from an exchange server with vb.net. Does anyone have an example of how to do this in any .NET language?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim session As New MSMAPI.MAPISession
Dim m As New MSMAPI.MAPIMessages

session = CreateObject("MAPI.Session", "exchange.mailserver.com")
session.UserName = "developertest"
session.Password = "developer"
Try
session.SignOn()

Catch ex As Exception
MessageBox.Show("not signed it")
End Try
MessageBox.Show("Done")
session.SignOff()

This is the code I have just fumbled through so far. But when I try to run it, it fails at session = CreateObject("MAPI.Session", "exchange.mailserver.com") with a message like cannot create active x component. Ideas, please?
[1018 byte] By [SuperGeek2007] at [2007-11-11 10:27:28]
# 1 Re: Using MAPI to read email
A quick Google search for "vb.net mapi.session" found this: http://blogs.ittoolbox.com/c/programming/archives/reading-email-using-mapi-in-vbnet-5855
Phil Weber at 2007-11-11 20:47:40 >
# 2 Re: Using MAPI to read email
Thank, but I did com accross that. I don't want to buy redemption.
SuperGeek2007 at 2007-11-11 20:48:48 >
# 3 Re: Using MAPI to read email
You should be able to modify that code to work without Redemption. It demonstrates how to use MAPI from VB.NET. Here are some other examples: http://www.google.com/search?q=c%23+exchange+mail
Phil Weber at 2007-11-11 20:49:48 >