Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Useing Redemption Object to Read an Inbox

Geek News

Useing Redemption Object to Read an Inbox
"Damian" <damianm[ at ]webaware.com.au> 6/6/2006 6:25:06 AM
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

Re: Useing Redemption Object to Read an Inbox
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 6/6/2006 1:43:35 PM
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" <damianm[ at ]webaware.com.au> wrote in message
news:1149575106.451270.184810[ at ]h76g2000cwa.googlegroups.com...
[Quoted Text]
> 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
>

Re: Useing Redemption Object to Read an Inbox
"Damian" <damianm[ at ]webaware.com.au> 6/6/2006 11:04:52 PM
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:
[Quoted Text]
> 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" <damianm[ at ]webaware.com.au> wrote in message
> news:1149575106.451270.184810[ at ]h76g2000cwa.googlegroups.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.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
> >

Re: Useing Redemption Object to Read an Inbox
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 6/7/2006 12:28:41 AM
NDRs are represented by the ReportItem object in OOM, not MailItem. That's
the reason you get the error.
To loop through the items in the Inbox folder, try something likee the
following (VB)

set Session = CreateObject("Redemption.RDOSession")
Session.Logon
set Inbox = Session.GetDefaultFolder(olFolderInbox)
set Items = Inbox.Items
for each Msg in Items
Debug.Print Msg.Subject
next

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Damian" <damianm[ at ]webaware.com.au> wrote in message
news:1149635092.061841.34140[ at ]f6g2000cwb.googlegroups.com...
[Quoted Text]
> 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" <damianm[ at ]webaware.com.au> wrote in message
>> news:1149575106.451270.184810[ at ]h76g2000cwa.googlegroups.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.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
>> >
>


Re: Useing Redemption Object to Read an Inbox
"Damian" <damianm[ at ]webaware.com.au> 6/7/2006 12:42:47 AM
Hi Dmitry,

Thanks for your reply. What are NDR's?
I need to be able to read the body an email bounceback. I am able to
read the body of a standard email, but I cant read the body of an email
bounce back. It returns empty.

Regards
Damian





Dmitry Streblechenko wrote:
[Quoted Text]
> NDRs are represented by the ReportItem object in OOM, not MailItem. That's
> the reason you get the error.
> To loop through the items in the Inbox folder, try something likee the
> following (VB)
>
> set Session = CreateObject("Redemption.RDOSession")
> Session.Logon
> set Inbox = Session.GetDefaultFolder(olFolderInbox)
> set Items = Inbox.Items
> for each Msg in Items
> Debug.Print Msg.Subject
> next
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "Damian" <damianm[ at ]webaware.com.au> wrote in message
> news:1149635092.061841.34140[ at ]f6g2000cwb.googlegroups.com...
> > 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" <damianm[ at ]webaware.com.au> wrote in message
> >> news:1149575106.451270.184810[ at ]h76g2000cwa.googlegroups.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.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
> >> >
> >

Re: Useing Redemption Object to Read an Inbox
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 6/7/2006 1:05:35 PM
NDR's are non-delivery reports. As Dmitry said and I indicated those items
are not MailItems, they are ReportItems and that's why your code is failing.
Use RDOMail instead of SafeMailItem, which is only for MailItem or use the
Redemption.MessageItem object.

--
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" <damianm[ at ]webaware.com.au> wrote in message
news:1149640967.831644.121220[ at ]j55g2000cwa.googlegroups.com...
[Quoted Text]
> Hi Dmitry,
>
> Thanks for your reply. What are NDR's?
> I need to be able to read the body an email bounceback. I am able to
> read the body of a standard email, but I cant read the body of an email
> bounce back. It returns empty.
>
> Regards
> Damian

Re: Useing Redemption Object to Read an Inbox
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 6/7/2006 4:58:54 PM
Also note that NDRs in most cases do not have a message body in tehe regular
sense (PR_BODY etc). What Outlook displays is created dynamically from
various properties in the recipient table - look at an NDR with OutlookSpy
(click IMessage, GetRecipientTable taab is what you need).
If you need to read the ND properties, use Recipient.Fields(); if you just
need all the data in a single blob a-la Outlook, use SafeReportItem in
Redemption and read the Body property.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> wrote in message
news:ez$dENjiGHA.3884[ at ]TK2MSFTNGP04.phx.gbl...
[Quoted Text]
> NDR's are non-delivery reports. As Dmitry said and I indicated those items
> are not MailItems, they are ReportItems and that's why your code is
> failing. Use RDOMail instead of SafeMailItem, which is only for MailItem
> or use the Redemption.MessageItem object.
>
> --
> 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" <damianm[ at ]webaware.com.au> wrote in message
> news:1149640967.831644.121220[ at ]j55g2000cwa.googlegroups.com...
>> Hi Dmitry,
>>
>> Thanks for your reply. What are NDR's?
>> I need to be able to read the body an email bounceback. I am able to
>> read the body of a standard email, but I cant read the body of an email
>> bounce back. It returns empty.
>>
>> Regards
>> Damian
>


Re: Useing Redemption Object to Read an Inbox
"Damian" <damianm[ at ]webaware.com.au> 6/8/2006 1:24:11 AM
Hi Dmitry and Ken,

Thanks for your help. What I still dont understand is what do I link
the Redemption SafeReportItem to ?

This is what I thought needed to be done

Dim Session As MAPI.Session
Dim Application, Namespace1
Dim Session2, BodyStr
Dim Inbox, Msg

Session = CreateObject("MAPI.Session")
Session.Logon(ProfileName:="profile_name",
ProfilePassword:="password")
Application = CreateObject("Outlook.Application")
Namespace1 = Application.GetNamespace("MAPI")
Namespace1.Logon()
Session2 = CreateObject("Redemption.RDOSession")
Session2.MAPIOBJECT = Application.Session.MAPIOBJECT
sRItem = CreateObject("Redemption.SafeReportItem")
Inbox = Session2.GetDefaultFolder(6)
For Each Msg In Inbox
sRItem.Item = Msg
BodyStr = sRItem.Body
Next

If anyone can point out where I am wrong it would be appreciated

Regards
Damian




Dmitry Streblechenko wrote:
[Quoted Text]
> Also note that NDRs in most cases do not have a message body in tehe regular
> sense (PR_BODY etc). What Outlook displays is created dynamically from
> various properties in the recipient table - look at an NDR with OutlookSpy
> (click IMessage, GetRecipientTable taab is what you need).
> If you need to read the ND properties, use Recipient.Fields(); if you just
> need all the data in a single blob a-la Outlook, use SafeReportItem in
> Redemption and read the Body property.
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> wrote in message
> news:ez$dENjiGHA.3884[ at ]TK2MSFTNGP04.phx.gbl...
> > NDR's are non-delivery reports. As Dmitry said and I indicated those items
> > are not MailItems, they are ReportItems and that's why your code is
> > failing. Use RDOMail instead of SafeMailItem, which is only for MailItem
> > or use the Redemption.MessageItem object.
> >
> > --
> > 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" <damianm[ at ]webaware.com.au> wrote in message
> > news:1149640967.831644.121220[ at ]j55g2000cwa.googlegroups.com...
> >> Hi Dmitry,
> >>
> >> Thanks for your reply. What are NDR's?
> >> I need to be able to read the body an email bounceback. I am able to
> >> read the body of a standard email, but I cant read the body of an email
> >> bounce back. It returns empty.
> >>
> >> Regards
> >> Damian
> >

Re: Useing Redemption Object to Read an Inbox
"Damian" <damianm[ at ]webaware.com.au> 6/8/2006 4:19:48 AM
Hi Dmitry and Ken,

Another problem is I want to be able to read an inbox which is set up
for bounce backs.
Some will have an automated response from the server in the body of the
email and some will have an out of office response or some other
response.

When you loop through an inbox how do you know whether to set the item
in the inbox to a SafeMailItem or SafeReportItem? Is there some sort of
test you can use?
The reason I asked is I just tried setting up a loop to read an inbox
and I set the SafeReportItem to the item in the inbox. It crashed as a
i got "a cast invalid" error.
The first item in the inbox was an out of office response not a an
automated server response. When i changed it and set the item to
SafeMailItem it was Ok until i came across an email with an automated
reponse from the server and got the same error, as this should have
been set to a SafeReportItem.

Am going nuts here! Any help would be appreciated...
Damian



Damian wrote:
[Quoted Text]
> Hi Dmitry and Ken,
>
> Thanks for your help. What I still dont understand is what do I link
> the Redemption SafeReportItem to ?
>
> This is what I thought needed to be done
>
> Dim Session As MAPI.Session
> Dim Application, Namespace1
> Dim Session2, BodyStr
> Dim Inbox, Msg
>
> Session = CreateObject("MAPI.Session")
> Session.Logon(ProfileName:="profile_name",
> ProfilePassword:="password")
> Application = CreateObject("Outlook.Application")
> Namespace1 = Application.GetNamespace("MAPI")
> Namespace1.Logon()
> Session2 = CreateObject("Redemption.RDOSession")
> Session2.MAPIOBJECT = Application.Session.MAPIOBJECT
> sRItem = CreateObject("Redemption.SafeReportItem")
> Inbox = Session2.GetDefaultFolder(6)
> For Each Msg In Inbox
> sRItem.Item = Msg
> BodyStr = sRItem.Body
> Next
>
> If anyone can point out where I am wrong it would be appreciated
>
> Regards
> Damian
>
>
>
>
> Dmitry Streblechenko wrote:
> > Also note that NDRs in most cases do not have a message body in tehe regular
> > sense (PR_BODY etc). What Outlook displays is created dynamically from
> > various properties in the recipient table - look at an NDR with OutlookSpy
> > (click IMessage, GetRecipientTable taab is what you need).
> > If you need to read the ND properties, use Recipient.Fields(); if you just
> > need all the data in a single blob a-la Outlook, use SafeReportItem in
> > Redemption and read the Body property.
> >
> > Dmitry Streblechenko (MVP)
> > http://www.dimastr.com/
> > OutlookSpy - Outlook, CDO
> > and MAPI Developer Tool
> >
> > "Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> wrote in message
> > news:ez$dENjiGHA.3884[ at ]TK2MSFTNGP04.phx.gbl...
> > > NDR's are non-delivery reports. As Dmitry said and I indicated those items
> > > are not MailItems, they are ReportItems and that's why your code is
> > > failing. Use RDOMail instead of SafeMailItem, which is only for MailItem
> > > or use the Redemption.MessageItem object.
> > >
> > > --
> > > 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" <damianm[ at ]webaware.com.au> wrote in message
> > > news:1149640967.831644.121220[ at ]j55g2000cwa.googlegroups.com...
> > >> Hi Dmitry,
> > >>
> > >> Thanks for your reply. What are NDR's?
> > >> I need to be able to read the body an email bounceback. I am able to
> > >> read the body of a standard email, but I cant read the body of an email
> > >> bounce back. It returns empty.
> > >>
> > >> Regards
> > >> Damian
> > >

Re: Useing Redemption Object to Read an Inbox
"Damian" <damianm[ at ]webaware.com.au> 6/8/2006 5:57:59 AM
Hi Dmitry and Ken,

I have worked it out. Thanks for putting me on the right track
Much appreciated.


Regards
Damian


Damian wrote:
[Quoted Text]
> Hi Dmitry and Ken,
>
> Another problem is I want to be able to read an inbox which is set up
> for bounce backs.
> Some will have an automated response from the server in the body of the
> email and some will have an out of office response or some other
> response.
>
> When you loop through an inbox how do you know whether to set the item
> in the inbox to a SafeMailItem or SafeReportItem? Is there some sort of
> test you can use?
> The reason I asked is I just tried setting up a loop to read an inbox
> and I set the SafeReportItem to the item in the inbox. It crashed as a
> i got "a cast invalid" error.
> The first item in the inbox was an out of office response not a an
> automated server response. When i changed it and set the item to
> SafeMailItem it was Ok until i came across an email with an automated
> reponse from the server and got the same error, as this should have
> been set to a SafeReportItem.
>
> Am going nuts here! Any help would be appreciated...
> Damian
>
>
>
> Damian wrote:
> > Hi Dmitry and Ken,
> >
> > Thanks for your help. What I still dont understand is what do I link
> > the Redemption SafeReportItem to ?
> >
> > This is what I thought needed to be done
> >
> > Dim Session As MAPI.Session
> > Dim Application, Namespace1
> > Dim Session2, BodyStr
> > Dim Inbox, Msg
> >
> > Session = CreateObject("MAPI.Session")
> > Session.Logon(ProfileName:="profile_name",
> > ProfilePassword:="password")
> > Application = CreateObject("Outlook.Application")
> > Namespace1 = Application.GetNamespace("MAPI")
> > Namespace1.Logon()
> > Session2 = CreateObject("Redemption.RDOSession")
> > Session2.MAPIOBJECT = Application.Session.MAPIOBJECT
> > sRItem = CreateObject("Redemption.SafeReportItem")
> > Inbox = Session2.GetDefaultFolder(6)
> > For Each Msg In Inbox
> > sRItem.Item = Msg
> > BodyStr = sRItem.Body
> > Next
> >
> > If anyone can point out where I am wrong it would be appreciated
> >
> > Regards
> > Damian
> >
> >
> >
> >
> > Dmitry Streblechenko wrote:
> > > Also note that NDRs in most cases do not have a message body in tehe regular
> > > sense (PR_BODY etc). What Outlook displays is created dynamically from
> > > various properties in the recipient table - look at an NDR with OutlookSpy
> > > (click IMessage, GetRecipientTable taab is what you need).
> > > If you need to read the ND properties, use Recipient.Fields(); if you just
> > > need all the data in a single blob a-la Outlook, use SafeReportItem in
> > > Redemption and read the Body property.
> > >
> > > Dmitry Streblechenko (MVP)
> > > http://www.dimastr.com/
> > > OutlookSpy - Outlook, CDO
> > > and MAPI Developer Tool
> > >
> > > "Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> wrote in message
> > > news:ez$dENjiGHA.3884[ at ]TK2MSFTNGP04.phx.gbl...
> > > > NDR's are non-delivery reports. As Dmitry said and I indicated those items
> > > > are not MailItems, they are ReportItems and that's why your code is
> > > > failing. Use RDOMail instead of SafeMailItem, which is only for MailItem
> > > > or use the Redemption.MessageItem object.
> > > >
> > > > --
> > > > 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" <damianm[ at ]webaware.com.au> wrote in message
> > > > news:1149640967.831644.121220[ at ]j55g2000cwa.googlegroups.com...
> > > >> Hi Dmitry,
> > > >>
> > > >> Thanks for your reply. What are NDR's?
> > > >> I need to be able to read the body an email bounceback. I am able to
> > > >> read the body of a standard email, but I cant read the body of an email
> > > >> bounce back. It returns empty.
> > > >>
> > > >> Regards
> > > >> Damian
> > > >

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net