Reading Email Programmatically

Hello folks. I am trying to write a program that will connect to a microsoft exchange server and read the email. I have heard that Microsoft MAPI is the way to go. I just have not figured out how to make it work. I have found lots of examples of how to send mail, but I have not been able to receive mail. Does anyone have a code sample I could check out? Is there a book someone can recommend? I have tried the following code and when I get to the CreateObject line I get an error like "Cannot create ActiveX control." Does anyone have suggestions? Is there a step I missed in the IDE?

Imports System.Web
Imports MSMAPI

Public Class Form1

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()

'session.DownLoadMail()

'm.Fetch()



End Sub
End Class
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories