none
Undelivered body mail content vba export to excel RRS feed

  • Question

  • Hi,

    In outlook 2013, I desperately try to export the body content of some reportitem but it doesn't work.

    I found a script that works for "normal" mails but it doesn't work for undelivered mail (notifications), why ? Any idea ?

    Hoping your help.

    Regards,

    EM

    Tuesday, October 31, 2017 9:53 AM

Answers

  • Hello,

    Please use PropertyAccessor.GetProperty Method (Outlook).

    Here is the example:

    Sub DemoPropertyAccessorGetProperty() 
     Dim PropName, Header As String 
     Dim oMail As Object 
     Dim oPA As Outlook.PropertyAccessor 
     'Get first item in the inbox 
     Set oMail = _ 
     Application.Session.GetDefaultFolder(olFolderInbox).Items(1) 
     'PR_TRANSPORT_MESSAGE_HEADERS 
     PropName = "http://schemas.microsoft.com/mapi/proptag/0x007D001E" 
     'Obtain an instance of PropertyAccessor class 
     Set oPA = oMail.PropertyAccessor 
     'Call GetProperty 
     Header = oPA.GetProperty(PropName) 
     Debug.Print (Header) 
    End Sub
    

    I do not have this kind of report item to test. According to the similar thread Eugene shared above, PR_TRANSPORT_MESSAGE_HEADERS contains the same Diagnostic information shown in Outlook body. Please test if you could get your expected result.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Elmata Monday, April 23, 2018 1:28 PM
    Friday, November 3, 2017 5:45 AM
    Moderator

All replies

  • Hi EM,

    Thanks for visiting our forum.

    Then here we mainly focus on general issues about Outlook client. Since your query is related to using script in Outlook, I'll move your thread to the following dedicated MSDN forum for Outlook:

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=outlookdev

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    Best regards,
    Yuki Sun


    Please remember to mark the replies as answers if they helped.

    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Wednesday, November 1, 2017 5:10 AM
  • Hello EM,

    What code do you have now?

    You need to deal with a ReportItem object, not MailItem. The ReportItem class is similar to a MailItem object, and it contains a report (usually the non-delivery report) or error message from the mail transport system.

    Unlike other Microsoft Outlook objects, you cannot create this object. Report items are created automatically when any report or error in general is received from the mail transport system.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Wednesday, November 1, 2017 3:33 PM
  • Hi & thanks Eugene.

    I would like to extract some informations in the non-delivery report that I received in my mail box.

    The attribute .body not seems to work/be called.

    How can I get this information in vba through outlook ?

    Regards,

    EM

    Wednesday, November 1, 2017 4:42 PM
  • EM,

    This is a known issue. There is a problem with ReportItem.Body property in the Outlook Object Model (Outlook 2013 and 2016). As a workaround you may consider using a low-level API or any other wrapper around that API such as Redemption. See Reading Body property of Outlook nondelivery receipt (NDR) item results in Chinese characters for more information. 


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Wednesday, November 1, 2017 5:59 PM
  • Hi & thx Eugene,

    What a pity !

    How can I use a low level API in outlook ? (because I don't want to install anything on my  my server mail)

    Regards,

    EM


    Thursday, November 2, 2017 11:29 AM
  • Hello,

    Please use PropertyAccessor.GetProperty Method (Outlook).

    Here is the example:

    Sub DemoPropertyAccessorGetProperty() 
     Dim PropName, Header As String 
     Dim oMail As Object 
     Dim oPA As Outlook.PropertyAccessor 
     'Get first item in the inbox 
     Set oMail = _ 
     Application.Session.GetDefaultFolder(olFolderInbox).Items(1) 
     'PR_TRANSPORT_MESSAGE_HEADERS 
     PropName = "http://schemas.microsoft.com/mapi/proptag/0x007D001E" 
     'Obtain an instance of PropertyAccessor class 
     Set oPA = oMail.PropertyAccessor 
     'Call GetProperty 
     Header = oPA.GetProperty(PropName) 
     Debug.Print (Header) 
    End Sub
    

    I do not have this kind of report item to test. According to the similar thread Eugene shared above, PR_TRANSPORT_MESSAGE_HEADERS contains the same Diagnostic information shown in Outlook body. Please test if you could get your expected result.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Elmata Monday, April 23, 2018 1:28 PM
    Friday, November 3, 2017 5:45 AM
    Moderator