View Single Post
  #3  
Old June 7th 06, 01:04 AM posted to microsoft.public.outlook.program_addins
Damian
external usenet poster
 
Posts: 6
Default Useing Redemption Object to Read an Inbox

Hi Ken,

Thanks for your response. I am sure they are MailItem objects as the
first time it loops through I could see the body of the email.
I need to be able to read the body of the email when it comes back from
a bounce back. Apparently there is a difference in reading the body of
an email from when someone sends an email to another person, compared
to when the server returns an automated message from a bounceback. I
dont have any experience in dealing with MAPI and messaging and I cant
find a full example of what I need to do on the Redemption website. It
seems to gives you bits and pieces but no full examples or am I missing
something?

Regards
Damian







Ken Slovak - [MVP - Outlook] wrote:
Are you sure the item or items in question are MailItem objects?

Using Redemption I'd probably use RDOMail objects and RDOFolder to get the
Inbox from the RDOSession object, that way I'd avoid problems like that.
Then I could check the Class or MessageClass of the RDOMail object before
working with it.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Damian" wrote in message
oups.com...
Hi,

I am looking for some help here. I am trying to read email from an
inbox. The emails are bouncebacks. I want to be able to parse the
message body to get email addesses etc.
Problem is it hangs on the first line -- oMsg = CType(oItems.Item(i),
Outlook.MailItem)
after it goes through one loop

Below is the code I am using.

Option Strict On
Imports System.ServiceProcess
Imports MAPI
Imports Outlook = Microsoft.Office.Interop.Outlook
Imports System.Runtime.InteropServices.Marshal
Imports System.Reflection
Imports Redemption

Dim BodyStr As String
Dim oApp As Outlook.Application = New Outlook.Application
Dim i As Integer

' Get Mapi NameSpace.
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("mapi")
oNS.Logon("outlook_profile", "password", False)

' Get Messages collection of Inbox.
Dim oInbox As Outlook.MAPIFolder =
oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFo lderInbox)
Dim oItems As Outlook.Items = oInbox.Items

' Loop each unread message.
Dim oMsg As Outlook.MailItem
Dim oSafeMsg As Redemption.SafeMailItem

For i = 1 To oItems.Count
oMsg = CType(oItems.Item(i), Outlook.MailItem) ' hangs on
this line after the first loop
oSafeMsg = New Redemption.SafeMailItem
oSafeMsg.Item = oMsg
BodyStr = oSafeMsg.Body

' parse code goes here

ReleaseComObject(oMsg)
oMsg = Nothing
Next

' Log off.
oNS.Logoff()

' Clean up.
ReleaseComObject(oApp)
oApp = Nothing
ReleaseComObject(oNS)
oNS = Nothing
ReleaseComObject(oItems)
oItems = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()


End Sub

Any ideas ? Any help would be appreciated

Thanks
Damian


Ads