Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Software > Developer Outlook Addins > Unable to chang...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 1636 of 1746
Post > Topic >>

Unable to change plain text mail within Outlook 2007

by boris.krivonog@[EMAIL PROTECTED] Dec 10, 2007 at 01:03 AM

Hi!

I have the following code within a COM Addin and Outlook 2007:

Outlook.MailItem mi = ActiveExplorer.Selection[1] as Outlook.MailItem;
if ( mi != null )
{
  Outlook.Inspector objInsp = mi.GetInspector;
  Word.Do***ent objDoc = objInsp.WordEditor as Word.Do***ent;
  objDoc.Content.InsertAfter( "This is a test! " );  // PROBLEM HERE
}

The code is executed within OnExplorerSelectionChange event. When
executed, the InsertAfter method throws a COMException with message
"This method or property is not available because the do***ent is
locked for editing.". Therefore, I tried to unprotect the do***ent
with

object missing = System.Reflection.Missing.Value;
Word.WdProtectionType protectionType = objDoc.ProtectionType;
if ( protectionType != Word.WdProtectionType.wdNoProtection )
    objDoc.Unprotect( ref missing );

before calling InsertAfter method. This seems to work for HTML mail,
but does NOT work for plain text mail. In case of a text mail, the
objDoc.Unprotect( ref missing ); method throws a COMException with
message "This command is not available".

Is there a way to get around this issue? Any help would be greatly
appreciated.
 




 2 Posts in Topic:
Unable to change plain text mail within Outlook 2007
boris.krivonog@[EMAIL PRO  2007-12-10 01:03:45 
Re: Unable to change plain text mail within Outlook 2007
"Sue Mosher [MVP-Out  2008-01-16 09:20:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 15:43:31 CST 2008.