Reading the Body of an Undeliverable e-mail 
Author Message
 Reading the Body of an Undeliverable e-mail

I would appreciate any help that anyone can offer. I am trying to write a VB
program that will loop through all of the undeliverable e-mails in a folder
that we have set up on our exchange server.  I need to grab the body or the
"to" e-mail address to flag the address as "bad" in our database.  I have
been able to grab the body of the mail if the e-mail is a MailItem, but for
undeliverable items, the object is a ReportItem.  There is a property for
the body but it always returns an empty string.  My code so far is as
follows:

    Dim objOutlookApp As Outlook.Application
    Dim objMapiFldr As Outlook.MAPIFolder

    Dim objReportItem As Outlook.ReportItem
    Dim intCounter As Integer, strProperty As String

    Set objOutlookApp = New Outlook.Application
    Set objMapiFldr =
objOutlookApp.GetNamespace("MAPI").Session.Folders("Mailbox").Folders("Inbox
")

     For intCounter = 1 To objMapiFldr.Items.Count
        Set objReportItem = objMapiFldr.Items.Item(intCounter)
       strProperty = objReportItem.Body
       MsgBox strProperty

    Next

    Set objMapiFldr = Nothing
    Set objReportItem = Nothing

I'm not sure why the Body property is available if it cannot be accessed.
Any help would be appreciated.

Thank you,

Jason Kemp



Wed, 28 Jul 2004 05:04:52 GMT  
 Reading the Body of an Undeliverable e-mail
A ReportItem never has anything in the Body property. The "body" that the user sees in the UI is built on-the-fly from undocumented MAPI properties on the item. A tool like Mdbvu32.exe or Outlook Spy (http://www.dimastr.com) will show you which ones might be useful. See http://www.cdolive.com/cdo10.htm for a primer on working with MAPI properties via CDO property tags.

--
Sue Mosher, Outlook MVP
   Outlook and Exchange Solutions
   at http://www.slipstick.com

Quote:

> I would appreciate any help that anyone can offer. I am trying to write a VB
> program that will loop through all of the undeliverable e-mails in a folder
> that we have set up on our exchange server.  I need to grab the body or the
> "to" e-mail address to flag the address as "bad" in our database.  I have
> been able to grab the body of the mail if the e-mail is a MailItem, but for
> undeliverable items, the object is a ReportItem.  There is a property for
> the body but it always returns an empty string.  My code so far is as
> follows:

>     Dim objOutlookApp As Outlook.Application
>     Dim objMapiFldr As Outlook.MAPIFolder

>     Dim objReportItem As Outlook.ReportItem
>     Dim intCounter As Integer, strProperty As String

>     Set objOutlookApp = New Outlook.Application
>     Set objMapiFldr =
> objOutlookApp.GetNamespace("MAPI").Session.Folders("Mailbox").Folders("Inbox
> ")

>      For intCounter = 1 To objMapiFldr.Items.Count
>         Set objReportItem = objMapiFldr.Items.Item(intCounter)
>        strProperty = objReportItem.Body
>        MsgBox strProperty

>     Next

>     Set objMapiFldr = Nothing
>     Set objReportItem = Nothing

> I'm not sure why the Body property is available if it cannot be accessed.
> Any help would be appreciated.

> Thank you,

> Jason Kemp




Wed, 28 Jul 2004 06:03:05 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. read email msg body

2. reading mail message body line by line

3. Trap undeliverable email message

4. unwanted emails retruned undeliverable

5. Trap undeliverable email message

6. Newbie Emailing text file into body of Email

7. ___ATTN___DON THOMAS_____mail returned "undeliverable" please read

8. Sending an email with format in the body from A2K

9. Populate Email Body with Query results

10. Insert fields from Access into Email body

11. eMail SQL results in message body

12. inserting date within email body/subject line

 

 
Powered by phpBB® Forum Software