none
Forwarding an outlook Reportitem RRS feed

  • Question

  • Hello,

    I'm working on a VB.net Outlook 2010 Add in using VSTO 2010.

    I've to forward items from outlook inbox.

    It all works fine with mail items, since the forward method applies.

    But how can I handle Report items ?

    Using the interface, it's possible to forward a report, so there must be a way to do it programmatically...

    Thank you for your help.

     

     

    Friday, September 14, 2012 9:33 AM

Answers

  • Attachments can't be dealt with directly. They have to be saved to the file system or extracted as Outlook items before you can work with them. So you can't just set an item equal to an attachment, it doesn't work that way.
     
    As you're already using Redemption, the easiest way I'd think would be to check each RDOAttachment for RDOAttachment.EmbeddedMsg. If it's null then it's not an embedded Outlook object, if not null it returrns an RDOMail object. If that is Class == olReport cast it as RDOReportItem and you're done.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Support BOSSARD" <=?utf-8?B?U3VwcG9ydCBCT1NTQVJE?=> wrote in message news:7a60705b-5fcd-4b50-9b00-28c7cef5daab...
    Hi,



    You're right  Attachments.Add(oReport) is the way to go, great idea thanks.

    This part now works, on the secretary side

    At the other side, I've to deal with the users recipient inbox, where I detect incoming mail from secretary, and automaticaly extract attachment as new item in the inbox (I know this may look like a strange organisation).Till now i was dealing with Mailitems only, and could extract attachment to file and add new mail in mailbox from saved file - maybe there would be a more direct way to do this like newmail = incommingmail.attachments(1) ? (actually that did not work)

    anyway what is working with Email has to be adapted to work with reports, and I as well need to detect what class is the attached item.

    Your ideas will be welcome on that as well

    Thank you

    Stéphane



    Ken Slovak MVP - Outlook
    Wednesday, September 19, 2012 4:58 PM

All replies

  • You would open or get a handle to the report item as an Outlook.ReportItem object. You would then need to copy whatever information you want from the item into a mail item and and use that mail item's Forward() method.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Support BOSSARD" <=?utf-8?B?U3VwcG9ydCBCT1NTQVJE?=> wrote in message news:96157db8-e30e-4a4a-a497-6e7d993ab84b...

    Hello,

    I'm working on a VB.net Outlook 2010 Add in using VSTO 2010.

    I've to forward items from outlook inbox.

    It all works fine with mail items, since the forward method applies.

    But how can I handle Report items ?

    Using the interface, it's possible to forward a report, so there must be a way to do it programmatically...

    Thank you for your help.

     

     


    Ken Slovak MVP - Outlook
    Friday, September 14, 2012 3:00 PM
  • Ken,

    Thank you for your answer. Of course that works fine until I need to know who the report was sent to (this inbox contents various recipients).

    I'm afraid that I now face the same problem as many others.... how to get the "to" information in a reportitem....

    -from message properties ? (if accessible - since I can read the inforamtion I need when checking the properties in file menu)

    - what about the idea of simulating the use of the forward button on the ribbon ? should I investigate on the button.performclick command, or any other ?
    -...

    Thank you for your help


    Monday, September 17, 2012 12:35 PM
  • A fake forward button won't get you anywhere.
     
    Those properties are unfortunately not directly exposed in the Outlook object model However, they are actually available at the MAPI property level, and can be accessed using the PropertyAccessor object. For example, sender would have a DASL property tag of "urn:schemas:httpmail:fromemail " for use with PropertyAccessor.
     
    Use either MFCMAPI or OutlookSpy to examine some report items to see what's there at the MAPI level, then use PropertyAccessor to get that information.
     
    Make sure to check a large sampling of report items, in my experience each different type of mail server sends different reports in different formats with different information.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Support BOSSARD" <=?utf-8?B?U3VwcG9ydCBCT1NTQVJE?=> wrote in message news:b4593278-64de-4bf3-930f-75a6bbd8d774...
    Ken,

    Thank you for your answer. Of course that works fine until I need to know who the report was sent to (this inbox contents various recipients).

    I'm afraid that I now face the same problem as many others.... how to get the "to" information in a reportitem....

    -from message properties ? (if accessible - since I can read the inforamtion I need when checking the properties in file menu)

    - what about the idea of simulating the use of the forward button on the ribbon ? should I investigate on the button.performclick command, or any other ?
    -...

    Thank you for your help



    Ken Slovak MVP - Outlook
    Monday, September 17, 2012 6:46 PM
  • ken,

    I'm starting to sort all that, using redemption at the end the get sender/recipient information.

    I now can create a new mail based on the reportitem details, then forward it, as you suggested.

    It seems that I have to save the "temp" mail in order to call the forward method. It will then remain as a draft.

    What is the best way to get something clean here ?

    deleting the mail from the draft afterward ?

    Thanks

    Tuesday, September 18, 2012 10:26 AM
  • If you can use Redemption you have other options than the workarounds we've been discussing.
     
    RDOReportItem has an exposed Recipients collection, has a ReportText property and a Forward() method and so on. Dmitry's done all the work with the MAPI fields to provide report information for you. That should make your task very simple.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Support BOSSARD" <=?utf-8?B?U3VwcG9ydCBCT1NTQVJE?=> wrote in message news:7370f245-97e6-45ae-94f3-e9aab40e2344...

    ken,

    I'm starting to sort all that, using redemption at the end the get sender/recipient information.

    I now can create a new mail based on the reportitem details, then forward it, as you suggested.

    It seems that I have to save the "temp" mail in order to call the forward method. It will then remain as a draft.

    What is the best way to get something clean here ?

    deleting the mail from the draft afterward ?

    Thanks


    Ken Slovak MVP - Outlook
    Tuesday, September 18, 2012 1:24 PM
  • Ken,



    I'm still fighting to get a valid solution....each time I can move forward a new unexpected problem appears (like always) Here are the various options I tried with problem faced - still tried our first approach and redemption, I'll see which works best at the end.

    A) Redemption / Reportitem forward

    pb 1 ) 

    I finally could make some tests using the foward method on my reportitem, then discovered that the "forward as attachment" outlook option is not applied there... can i force this ?

    pb 2)

    During my test I moved manually my report in the default inbox so I could easily find it.

    In fact My forward action will be launched through a button available on an inspector window after the report as been double clicked.

    in order to apply the forward method I need to identify my report inside redemption session, right ? 

    So   I tried  

     RDOsession= CreateObject("Redemption.RDOSession")

     RDOsession.MAPIOBJECT = oApp.Session.MAPIOBJECT

     MyReport = RDOsession.GetItemFromID(InpuReport.EntryID)

    >>> I got Missingmemberexception error



    B) new mail + forward

    I was almost done with copying details into a new mail then forwarding it - but the forwarded mail is still editable - how to transform a new mail into a received style mail ?



    That's several questions at time, sorry about that, it 'll make understand what's going on and go for adapted solution.



    Thanks again for your help


    Wednesday, September 19, 2012 1:07 PM
  • If you want to forward the report as an attachment on a different item (MailItem) why not just create the mail item and add the report as an attachment using Attachments.Add(oReport), where oReport is a ReportItem.
     
    BTW, Forward as attachment is only available as a rule action, not as a normal Outlook method.
     
    If the report was double-clicked it was opened, correct? So it would now be displayed in an Inspector window. Even if multiple Inspectors are opened you can iterate the collection to find an item where Inspector.CurrentItem.Class == olReport. Once found you can get your ReportItem reference from Inspector.CurrentItem.
     
    If you have that you have the item.EntryID, which allows you to get the item using RDO.You may have to supply the optional arguments to GetMessageFromID, depending on the framework version and language version used. In that case using System.Reflection.Missing.Value for StoreID and Flags might be needed. You'd also need to cast the returned RDOMail item as an RDOReportItem to be able to use the special report properties.
     
    I'm not sure what you mean about making a new mail look like a received mail. Aren't you forwarding the new mail once you have the data you want in it? If so it would become a sent item once forwarded, not a received item.
     
    I've made RDOMail items I've created make look sent by setting all the appropriate properties before the first time the item was saved. Before that you can set a number of properties that once the item is saved become read-only. So by setting all the senderXXX properties and some others I can make the item look sent.
     
    I've never tried to make an item look received when it wasn't however, so I don't know if it would work.
     I'd use OutlookSpy to examine actual received items and a new item to see exactly what properties need to be set. If that works the item should look received.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Support BOSSARD" <=?utf-8?B?U3VwcG9ydCBCT1NTQVJE?=> wrote in message news:e1f46c8d-ec82-4abe-a214-7d3863d9178c...
    Ken,



    I'm still fighting to get a valid solution....each time I can move forward a new unexpected problem appears (like always) Here are the various options I tried with problem faced - still tried our first approach and redemption, I'll see which works best at the end.

    A) Redemption / Reportitem forward

    pb 1 ) 

    I finally could make some tests using the foward method on my reportitem, then discovered that the "forward as attachment" outlook option is not applied there... can i force this ?

    pb 2)

    During my test I moved manually my report in the default inbox so I could easily find it.

    In fact My forward action will be launched through a button available on an inspector window after the report as been double clicked.

    in order to apply the forward method I need to identify my report inside redemption session, right ? 

    So   I tried  

     RDOsession= CreateObject("Redemption.RDOSession")

     RDOsession.MAPIOBJECT = oApp.Session.MAPIOBJECT

     MyReport = RDOsession.GetItemFromID(InpuReport.EntryID)

    >>> I got Missingmemberexception error



    B) new mail + forward

    I was almost done with copying details into a new mail then forwarding it - but the forwarded mail is still editable - how to transform a new mail into a received style mail ?



    That's several questions at time, sorry about that, it 'll make understand what's going on and go for adapted solution.



    Thanks again for your help



    Ken Slovak MVP - Outlook
    Wednesday, September 19, 2012 2:17 PM
  • Hi,



    You're right  Attachments.Add(oReport) is the way to go, great idea thanks.

    This part now works, on the secretary side

    At the other side, I've to deal with the users recipient inbox, where I detect incoming mail from secretary, and automaticaly extract attachment as new item in the inbox (I know this may look like a strange organisation).Till now i was dealing with Mailitems only, and could extract attachment to file and add new mail in mailbox from saved file - maybe there would be a more direct way to do this like newmail = incommingmail.attachments(1) ? (actually that did not work)

    anyway what is working with Email has to be adapted to work with reports, and I as well need to detect what class is the attached item.

    Your ideas will be welcome on that as well

    Thank you

    Stéphane


    Wednesday, September 19, 2012 3:43 PM
  • Attachments can't be dealt with directly. They have to be saved to the file system or extracted as Outlook items before you can work with them. So you can't just set an item equal to an attachment, it doesn't work that way.
     
    As you're already using Redemption, the easiest way I'd think would be to check each RDOAttachment for RDOAttachment.EmbeddedMsg. If it's null then it's not an embedded Outlook object, if not null it returrns an RDOMail object. If that is Class == olReport cast it as RDOReportItem and you're done.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Support BOSSARD" <=?utf-8?B?U3VwcG9ydCBCT1NTQVJE?=> wrote in message news:7a60705b-5fcd-4b50-9b00-28c7cef5daab...
    Hi,



    You're right  Attachments.Add(oReport) is the way to go, great idea thanks.

    This part now works, on the secretary side

    At the other side, I've to deal with the users recipient inbox, where I detect incoming mail from secretary, and automaticaly extract attachment as new item in the inbox (I know this may look like a strange organisation).Till now i was dealing with Mailitems only, and could extract attachment to file and add new mail in mailbox from saved file - maybe there would be a more direct way to do this like newmail = incommingmail.attachments(1) ? (actually that did not work)

    anyway what is working with Email has to be adapted to work with reports, and I as well need to detect what class is the attached item.

    Your ideas will be welcome on that as well

    Thank you

    Stéphane



    Ken Slovak MVP - Outlook
    Wednesday, September 19, 2012 4:58 PM
  • Ken,



    Thanks to all your advices I could achieve what I wanted to, so it's time to deploy my solution and wait for feed back.

    Thanks you very much for your help

    Stéphane

    Thursday, September 20, 2012 3:29 PM