none
Received read receipt can not convert to mail item. RRS feed

  • Question

  • Hi All,

    Thank you for reading this.

    I am iterating through the mail items of a folder and want to save the read receipt of the received email from outlook using the save as method to the physical hard drive as a msg format. I am converting  the Item to MailItem  interface which works for the received emails in the folder but not the read receipt emails in the folder.

    Please help me sort out the same. 

    Cheers,

    :)

    Saturday, February 11, 2012 8:28 AM

Answers

  • What is wrong with ReportItem.SaveAs? Does it not work for you?

    Do you get an error? What is your code?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!

    • Marked as answer by Veenit M Friday, February 24, 2012 3:04 AM
    Wednesday, February 22, 2012 5:23 AM

All replies

  • You can set the MessageClass property to IPM.Note to convert to MailItem.

    But why do you need to convert ReportItem to MailItem to begin with?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!

    Saturday, February 11, 2012 4:58 PM
  • Thank you for your reply.  Please excuse me for no response for few days.

    We want to backup all the items in the inbox to a physical file on regular intervals. I am aware that outlook does have the archiving facility, also many other products are avialable to have a backup. 

    I would try your solution and will update in a few days.

    Cheers,

    Wednesday, February 22, 2012 4:54 AM
  • What is wrong with ReportItem.SaveAs? Does it not work for you?

    Do you get an error? What is your code?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!

    • Marked as answer by Veenit M Friday, February 24, 2012 3:04 AM
    Wednesday, February 22, 2012 5:23 AM
  • Thank you for your reply.

    Since I am doing this as a part for my learning and so I cannot spend more time on weekdays. Below is the extract of the function. The other thing I am trying to do is get specific items in the date range of the selected folder and date period .. :)

     private void writetofolder(string ID)
            {
                MAPIFolder currentFolder = appObject.Session.GetFolderFromID(ID, Type.Missing);
                Microsoft.Office.Interop.Outlook.Items items = currentFolder.Items;

                string fileName = string.Empty;
                string fullpath = string.Empty;
                string path = GetPath(ID);


               foreach (Object item in items)
                {
                    try
                    {
                        mail = (Microsoft.Office.Interop.Outlook._MailItem)item;
                        fileName = GetFileName(mail.Subject.ToString());
                        fullpath = string.Format(path + "\\" + fileName + ".msg");
                        mail.SaveAs(fullpath, OlSaveAsType.olMSG);
                        mail = null;
                    }
                    catch (System.Exception ex)
                    {


                    }

                }
            }

    Friday, February 24, 2012 2:56 AM
  • Thank you Dmitry,

    Items belong to different class e.g. MailItem (43), ReportItem (46) etc. So we need to typecast to the sepecific type. Please correct me if I am wrong. Can anyone help me list out all the possible types in a folder and how to write a case switch structure to convert the same.

    Cheers,

    Vinit M

    Friday, February 24, 2012 3:06 AM
  • Yes, you will need to use the "is" operator to figure out the type. Or use late binding and check the Class property.

    Or just use late binding to call the SaveAs method.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!

    Friday, February 24, 2012 6:09 AM