• Subject: Problem reading e-mail from exchange 2003 programmatically
  • Author: bijan@kamrava.com
  • Date: 04 Dec 2007
  • References:
Hello all,

I have some programs that uses the code below and does not give me any
problem. However recently I copied the same code and now it generate
error when it hit the line
objInbox = objSession.Inbox
Can someone please give me an alternate method to read e-mails without
using CDO?

The error message is this:

System.Runtime.InteropServices.COMException was caught
ErrorCode=-2147221219
Message="Microsoft Exchange is not available. Either there are
network problems or the Exchange computer is down for maintenance.
[Microsoft Exchange Information Store -
[MAPI_E_FAILONEPROVIDER(8004011D)]]"
Source="Collaboration Data Objects"

Code snippet
--------------------

Dim objSession As MAPI.Session
Dim objInbox As MAPI.Folder
Dim objMessages As MAPI.Messages
Dim objMessage As MAPI.Message
Dim objMsgFilter As MAPI.MessageFilter
Dim objAttachment As MAPI.Attachment
Dim strProfileInfo As String

strProfileInfo = "Exchange.EmailServer" & vbLf & "E-mail
Alias"
objSession = CreateObject("MAPI.Session")
objSession.Logon(ProfileInfo:=strProfileInfo,
ShowDialog:=False)
'reference the messages in the inbox
objInbox = objSession.Inbox 'get the Inbox object
collection
objMessages = objInbox.Messages 'get the messages
object collection
objMsgFilter = objMessages.Filter 'get the Message
Filter object collection
For Each objMessage In objInbox.Messages
If Not objMessage.Unread Then
' Do somthing with the attachement
End If ' objMessage.Unread

Next objMessage
04 Dec 2007Problem reading e-mail from exchange 2003 programmatically.bijan@kamrava.com
04 Dec 2007|- Re: Problem reading e-mail from exchange 2003 programmatically.Ken Slovak - [MVP - O...
04 Dec 2007|  |- Re: Problem reading e-mail from exchange 2003 programmatically.bijan@kamrava.com
05 Dec 2007|  |  \ Re: Problem reading e-mail from exchange 2003 programmatically.Ken Slovak - [MVP - O...
05 Dec 2007|  |     \ Re: Problem reading e-mail from exchange 2003 programmatically.Dmitry Streblechenko
05 Dec 2007|  |        \ Re: Problem reading e-mail from exchange 2003 programmatically.Ken Slovak - [MVP - O...
17 Jan 2008|  \ Re: Problem reading e-mail from exchange 2003 programmatically.ranjeet.knit@gmail.com
11 Apr 2008\ RE: Problem reading e-mail from exchange 2003 programmatically.Andre Calanas
11 Apr 2008   \ Re: Problem reading e-mail from exchange 2003 programmatically.Dmitry Streblechenko
All times are in (US) Eastern Daylight Time (GMT -4:00)