none
Content Controls in Outlook Read Panes RRS feed

  • Question

  • I'm using VS2010 SP1, C#, Outlook 2010, .NET 4.0.  My Add-In applies content controls to the message document editor when a mail message is being composed.  I embed the control locations and content in an attachment that is sent with the mail message item as Outlook strips the content controls from the mail message when it gets sent.   This works well.

     

    When the mail message arrives at the destination, I want to recreate the content controls in the reading pane of the receiving Outlook (2010) application.  The reading panel does not allow me to add content controls to the document editor as it throws an error indicating the document is 'locked'.  Is there any way to 'unlock' the document or a work around for this situaton? 

    Wednesday, June 29, 2011 5:28 PM

Answers

  • Does the Protect() method work if you call it with an argument of WdProtectionType.wdNoProtection ?
     
    If that doesn't work you could try using Inspector.CommandBars.ExecuteMso("EditMessage") to try to put the item into edit mode.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "et-Cliff" <=?utf-8?B?ZXQtQ2xpZmY=?=> wrote in message news:2de0cacc-7501-46cf-83c6-074b21715989...

    It appears that content controls can only be added if the message is in compose mode.  The underlying Word document used in read mode always appears 'locked'.  In read mode you can modify the message body text or html but not the document.  (Unless I'm missing something.)

    Word.Document myDoc = mailItem.GetInspector.WordEditor as Word.Document;

    object start = 1;

    object end = 5;

    Word.Range range = myDoc.Range(ref start, ref end);

    object rng = range;

    // this next line throws an error if maitItem is in a read inspector

    Word.ContentControl myCC = myDoc.ContentControls.Add(Word.WdContentControlType.wdContentControlRichText, ref rng);

     


    Ken Slovak MVP - Outlook
    • Marked as answer by Bruce Song Monday, July 11, 2011 3:53 AM
    Tuesday, July 5, 2011 1:45 PM
  • In the end, my customer was satisfied with the ability to modify the body of the received message to display the sent text without the content controls. 

    At some point in the development cycle I will investigate the 'EditMessage' suggestion but delivery is pending.  So I will mark this as answered for now.

    • Marked as answer by cmm-Cliff Monday, July 18, 2011 5:18 PM
    Monday, July 18, 2011 5:17 PM

All replies

  • Have you tried using code for NewMailEx() that tries to handle that when the item isn't selected for view in the preview pane?
     
    Do your controls display OK in the preview pane on an item where the controls are added but it hasn't been sent yet? If they don't display in that case they might not ever display at the other end.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "et-Cliff" <=?utf-8?B?ZXQtQ2xpZmY=?=> wrote in message news:ecb8f3d1-10b6-418a-a559-334c9fb03339...

    I'm using VS2010 SP1, C#, Outlook 2010, .NET 4.0.  My Add-In applies content controls to the message document editor when a mail message is being composed.  I embed the control locations and content in an attachment that is sent with the mail message item as Outlook strips the content controls from the mail message when it gets sent.   This works well.

     

    When the mail message arrives at the destination, I want to recreate the content controls in the reading pane of the receiving Outlook (2010) application.  The reading panel does not allow me to add content controls to the document editor as it throws an error indicating the document is 'locked'.  Is there any way to 'unlock' the document or a work around for this situaton? 


    Ken Slovak MVP - Outlook
    Wednesday, June 29, 2011 6:26 PM
  • Hi Ken,

    The controls do display correctly if I save the unsent message in the Drafts folder. 

    I am unfamiliar with NewMailEX(), you may need to point me to some examples

    Cliff

    Wednesday, June 29, 2011 7:43 PM
  • NewMailEx() is an event on the Outlook.Application object and fires when one or more new emails are added to the Inbox. It provides a list of EntryId's for the incoming emails.
     
    The instantiation of the event would look something like this:
       
        this.Application.NewMailEx += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_NewMailExEventHandler(Application_NewMailEx);
     
    The event handler looks like this:
     

    void Application_NewMailEx(string EntryIDCollection)

    {

    throw new NotImplementedException();

    }

    You get a list separated by commas if more than 1 email is being handled by the event.

    You can take the email item and work with your controls either there in Inbox, or you can move the item somewhere like Drafts and then work on it and move it back to Inbox.

    The Outlook VBA Object Browser Help for the event has a sample, although it's not very informative. There might be other samples if you do a search at www.outlookcode.com for "NewMailEx".

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "et-Cliff" <=?utf-8?B?ZXQtQ2xpZmY=?=> wrote in message news:d539f48f-6359-4fd5-a32c-d5f46233821e...

    Hi Ken,

    The controls do display correctly if I save the unsent message in the Drafts folder. 

    I am unfamiliar with NewMailEX(), you may need to point me to some examples

    Cliff


    Ken Slovak MVP - Outlook
    Wednesday, June 29, 2011 8:19 PM
  • Hi Cliff,

    What is the status of the problem on your side? If you still show any concern on the post, just feel free to follow up.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 5, 2011 9:39 AM
  • It appears that content controls can only be added if the message is in compose mode.  The underlying Word document used in read mode always appears 'locked'.  In read mode you can modify the message body text or html but not the document.  (Unless I'm missing something.)

    Word.Document myDoc = mailItem.GetInspector.WordEditor as Word.Document;

    object start = 1;

    object end = 5;

    Word.Range range = myDoc.Range(ref start, ref end);

    object rng = range;

    // this next line throws an error if maitItem is in a read inspector

    Word.ContentControl myCC = myDoc.ContentControls.Add(Word.WdContentControlType.wdContentControlRichText, ref rng);

     

    Tuesday, July 5, 2011 12:32 PM
  • Does the Protect() method work if you call it with an argument of WdProtectionType.wdNoProtection ?
     
    If that doesn't work you could try using Inspector.CommandBars.ExecuteMso("EditMessage") to try to put the item into edit mode.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "et-Cliff" <=?utf-8?B?ZXQtQ2xpZmY=?=> wrote in message news:2de0cacc-7501-46cf-83c6-074b21715989...

    It appears that content controls can only be added if the message is in compose mode.  The underlying Word document used in read mode always appears 'locked'.  In read mode you can modify the message body text or html but not the document.  (Unless I'm missing something.)

    Word.Document myDoc = mailItem.GetInspector.WordEditor as Word.Document;

    object start = 1;

    object end = 5;

    Word.Range range = myDoc.Range(ref start, ref end);

    object rng = range;

    // this next line throws an error if maitItem is in a read inspector

    Word.ContentControl myCC = myDoc.ContentControls.Add(Word.WdContentControlType.wdContentControlRichText, ref rng);

     


    Ken Slovak MVP - Outlook
    • Marked as answer by Bruce Song Monday, July 11, 2011 3:53 AM
    Tuesday, July 5, 2011 1:45 PM
  • The Protect() method throws an error: "The Protect method or property is not available because the document is locked for editing."  (Even though it's being opened for 'Read')

     

    Trying the "EditMessage" suggestion next......

    Wednesday, July 6, 2011 7:18 PM
  • Hi et-Cliff,

    What is the status of the problem on your side? Have you tried "EditMessage" suggestion and whether it works well on your side? If you still show any concern on the thread, just feel free to follow up.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, July 8, 2011 8:03 AM
  • In the end, my customer was satisfied with the ability to modify the body of the received message to display the sent text without the content controls. 

    At some point in the development cycle I will investigate the 'EditMessage' suggestion but delivery is pending.  So I will mark this as answered for now.

    • Marked as answer by cmm-Cliff Monday, July 18, 2011 5:18 PM
    Monday, July 18, 2011 5:17 PM