D
Damian
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.olFolderInbox)
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
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.olFolderInbox)
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