none
Identified preview pane (reading view) send RRS feed

  • Question

  • Hello,

    I have bug when send a mailItem after trying to close is Inspector. To get this bug i need the mailItem be a draft Item open in preview mode.

    1. Is there a way to know if the Inspector is in the preview panel ( Sometime call "reading view" maybe ).

    2. Is there a way to know if the mail is a draft (depreceate since it mean i don't gonna close the inspector if the user reopen the mail).

    I have tryed :

    Outlook.Folder tryInsp = mail.Parent as Outlook.Folder;
    tryInsp.CurrentView.Name.Contains("Draft");

    But i fear since Some draft folder didn't have the same name that one day it didn't containt the word "Draft"...

    Monday, May 11, 2015 2:26 PM

Answers

  • Try to use the ActiveInlineResponse property of the Explorer class which returns an item object representing the active inline response item in the explorer reading pane.

    The size-related properties can be used to identify whether a separate inspector window is shown to a user.

    • Marked as answer by Aurelien312 Monday, May 11, 2015 4:24 PM
    Monday, May 11, 2015 3:46 PM

All replies

  • Hello Aurelien,

    What bug are you talking about? Could you be more specific?

    > 1. Is there a way to know if the Inspector is in the preview panel ( Sometime call "reading view" maybe ).

    Try to use the ActiveInlineResponse property of the Explorer class which returns an item object representing the active inline response item in the explorer reading pane.

    2. Is there a way to know if the mail is a draft (depreceate since it mean i don't gonna close the inspector if the user reopen the mail).

    You can use the PR_MESSAGE_FLAGS property value for identifying the state of the message. Search for the MSGFLAG_UNSENT flag value.  The PropertyAccessor class can be used for accessing the property value. The DASL name is http://schemas.microsoft.com/mapi/proptag/0x0E070003.

    Monday, May 11, 2015 2:31 PM
  • Ill get an Exception when i send the mail. With the generic exception code.

    Monday, May 11, 2015 2:33 PM
  • What code do you use for sending emails?
    Monday, May 11, 2015 2:37 PM
  • The Exeception. In french sorry. I'll try my best to change my Outlook language but Outlook didn't want. I hate french.

    System.Runtime.InteropServices.COMException was caught
      _HResult=-2147467259
      _message=Cette méthode ne peut pas être utilisée avec un élément de message de réponse inclus.
      HResult=-2147467259
      IsTransient=false
      Message=Cette méthode ne peut pas être utilisée avec un élément de message de réponse inclus.
      Source=Microsoft Outlook
      ErrorCode=-2147467259
      StackTrace:
           à Microsoft.Office.Interop.Outlook._MailItem.Send()
           à Model.MailManager.<OnSend>b__6() dans {file path here}
      InnerException:

    My code:

    ((_Inspector) _mail.GetInspector).Close(OlInspectorClose.olDiscard);
     mail.Send();


    • Edited by Aurelien312 Monday, May 11, 2015 2:49 PM confidential
    Monday, May 11, 2015 2:45 PM
  • The inspector window is closed automatically if you send the mail item in Outlook. Try to remove the Close method call from the code.
    Monday, May 11, 2015 2:48 PM
  • I can't:

    publicvoid FakeOnSend(refbool Cancel) {           Cancel =true;           SendTasks =Task.Factory.StartNew(() => {               var mail = (_mail as_MailItem);                             ((_Inspector)_mail.GetInspector).Close(OlInspectorClose.olDiscard);               // really heavy and bad code for the fake               mail.HTMLBody =Helper.AppendSignature(mail.HTMLBody, Helper.GetAttachmentHtml(GetLinks(), Manager.User.Url, mail.Attachments));               Outlook.ItemEvents_10_Event mailEvent = ((Outlook.ItemEvents_10_Event)_mail);               mailEvent.Close -= OnClose;               mailEvent.Write -= OnSave;               mailEvent.BeforeAutoSave -= OnSave;               mailEvent.BeforeAttachmentAdd -= OnAttachmentAdd;               mailEvent.Send -= OnSend;               try {                   mail.Send();               } catch (System.Exception ex) { // Where the errors happendvar hf = Dlinks.Count + UploadTasks.Count + ex.Message;                   hf = UploadTasks.Count + Dlinks.Count + ex.Message;               }           });           _mailManagers.Remove(this);       }

                             

    Monday, May 11, 2015 3:00 PM
  • First of all, you shouldn't use the Outlook object model from a secondary thread. Always use the main thread only when you deal with the Outlook object model. Office applications use the single threaded apartments. 

    Did you try to check out the inspector object properties like width, height, top, left and etc.?

    Monday, May 11, 2015 3:24 PM
  • First of all, you shouldn't use the Outlook object model from a secondary thread. Always use the main thread only when you deal with the Outlook object model. Office applications use the single threaded apartments. 

    I know but i must do this on a second thread... Otherwise the user interface going to be block waiting the mail to be send.

    Monday, May 11, 2015 3:32 PM
  • Did you try to check out the inspector object properties like width, height, top, left and etc.?

    Yeah i try and found "mail.Parent as Outlook.Folder;". Like sayed earlyer. But it didn't work as i want to. I have also tried to compare with :
    Outlook._Application olApp = new Outlook.Application();
    Outlook._NameSpace olNS = olApp.GetNamespace("MAPI");
    Outlook.MAPIFolder oFolder = olNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDrafts);
    But with no result. The two are different folder....
    Monday, May 11, 2015 3:38 PM
  • Try to use the ActiveInlineResponse property of the Explorer class which returns an item object representing the active inline response item in the explorer reading pane.

    The size-related properties can be used to identify whether a separate inspector window is shown to a user.

    • Marked as answer by Aurelien312 Monday, May 11, 2015 4:24 PM
    Monday, May 11, 2015 3:46 PM
  • For what i see. It's seem to work. I'll going to make some test before close the subject. But thanks a lot for your help.
    Monday, May 11, 2015 4:10 PM
  • Again, don't use OOM on the secondary threads. If required, you can use the low-level API - Extended MAPI or any other third-party wrappers around that API such as Redemption.
    Monday, May 11, 2015 4:54 PM