none
Can i add hyperlink to the received Plain-Text email content? It says protected and read-only. RRS feed

  • Question

  • I want to select the start and end range of text in the received plain-text format email and and add hyperlink to the selected range of the text. Through outlook objects, i cannot select particular text in the mail body,so i am converting the outlook inspector to word editor and trying to add hyperlink to the particular  selection of the text.  I am getting the below error when i am trying to add hyperlink to the selected content.
    Microsoft.Office.Interop.Word._Document document; //I am getting this document protection type as wdAllowOnlyReading;

    Microsoft.Office.Interop.Word.Hyperlink hl = document.Content.Hyperlinks.Add(....)

    Exception Message :"Out of memory"

    Stack Trace at : Microsoft.Office.Interop.Word.Hypherlinks.Add(....)

    After getting this error message, i was trying to change the protection property of the doucment and i couldn't do that and i am getting the below auto intellisense error.

     document.ProtectionType = WdProtectionType.wdNoProtection;

    Auto Intellisense Error : "Property or indexer 'Microsoft.Interop.Word.Docment.ProtectionType' cannot be assigned to -- it is read only."

    I am able to successfully  add hyperlinks to the email contents when received email in HTML,Rich text format. Also i am able to do hyperlink the mail content when i have a plain-text format email in compose mode.  I am facing the above error when i am trying to add hyperlink to the received plain-text email.

    Thanks a lot for your help and time in advance.


    http://www.selvaonline.com - Live a Happy & Balanced Life


    • Edited by SelvaOnline Wednesday, March 12, 2014 3:19 AM
    Tuesday, March 11, 2014 9:26 PM

Answers

  • Hi Selva,

    We can't add hyperlinks if emails are plain text format. This is by designed.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by SelvaOnline Wednesday, March 19, 2014 1:01 PM
    Wednesday, March 19, 2014 7:20 AM
    Moderator
  • Selva,

    Well, it confirms my assumptions.

    You need to set the BodyFormat property first to change the plain text message to the html one. Then you will be able to add hyperlinks (even with the Word editor).

    • Marked as answer by SelvaOnline Wednesday, March 19, 2014 1:00 PM
    Wednesday, March 19, 2014 7:48 AM
  • Hi Eugene,

    Yes I did like that. But i can edit the received email :) after converting BodyFormat to HTML. Its look like a bug in the office. There is no security exist to the user if anyone can edit the received mail. So i have changed the plaintext format to Richtext and adding hyperlinks.

    Regards,

    Selva


    http://www.selvaonline.com - Live a Happy & Balanced Life

    • Marked as answer by SelvaOnline Wednesday, March 19, 2014 1:00 PM
    Wednesday, March 19, 2014 11:22 AM

All replies

  • You probably need to call the Document's Unprotect method.

    Peter Jamieson

    Tuesday, March 11, 2014 8:40 PM
  • How to do that :) Please help .

    http://www.selvaonline.com - Live a Happy & Balanced Life

    Tuesday, March 11, 2014 8:42 PM
  •   document.Unprotect();   - Let me try this method and let you know.

    http://www.selvaonline.com - Live a Happy & Balanced Life

    Tuesday, March 11, 2014 8:44 PM
  • I am getting the error as "This command is not available." when i am using  document.Unprotect();  

    I am using the above word document object in outlook add-in to read and add hyperlink to the plain-text email content.

    I am able to add hyperlinks to the email contents when received email format is HTML,Rich text. But i am not able to insert hyperlink to the plain-text format emails. Kindly help.



    http://www.selvaonline.com - Live a Happy & Balanced Life

    Tuesday, March 11, 2014 9:12 PM
  • I'm not really that familiar about how to do things in an Outlook environment, but my guess is that if you are trying to create or modifying a plain text email body, inserting a hyperlink object into a Word document probably isn't the simplest way to do it: in a plain text email, the only thing you should insert is the plain text hyperlink address+subaddress. (Unlike a Word Hyperlink object, there would be no display text or tip text).

    Peter Jamieson

    Tuesday, March 11, 2014 9:30 PM
  • Hello Selva,

    Did you try to use the HTMLBody property instead of Word editor? Does it work as expected? Do you get any error messages?

    Tuesday, March 11, 2014 9:33 PM
  • Thanks for your response.
    Outlook cannot get the selected text in the mail body,so i am converting the outlook to word editor. Also HTMLBODY will not support range objects for selection of the text  where word object model does.



    http://www.selvaonline.com - Live a Happy & Balanced Life

    Tuesday, March 11, 2014 9:41 PM
  • Thank you for the additional explanation. It looks like you missed my questions from my previous post there.

    Did you try to use the HTMLBody property instead of Word editor? Does it work as expected? Do you get any error messages?

    Tuesday, March 11, 2014 9:59 PM
  • Hello Selva,

    First of all, the issue is not related to VSTO at all.

    Here is the first your forum post in the Word for Developers forum - Property or indexer 'Microsoft.Interop.Word.Docment.ProtectionType' cannot be assigned to -- it is read only. .

    The second topic I see in the Outlook for Developers forum - Can i add hyperlink to the received Plain-Text email content? It says protected and read-only.

    Could you please stop spamming forums and ask questions only in the single forum thread?

    Tuesday, March 11, 2014 10:49 PM
  • Hi Eugene,

    Sorry about that. I have removed the duplicate questions. Do you have any thought on my issue? Thanks for your help in advance.

    Regards,

    Selva


    http://www.selvaonline.com - Live a Happy & Balanced Life


    • Edited by SelvaOnline Wednesday, March 12, 2014 3:20 AM
    Wednesday, March 12, 2014 3:00 AM
  • Hello Selva,

    It looks like you missed my questions from my previous post there.

    Did you try to use the HTMLBody property instead of Word editor? Does it work as expected? Do you get any error messages?

    Wednesday, March 12, 2014 8:54 AM
  • @Fei

    document.unprotect() method is giving the exception as "This command is not available."

    @Eugene,

    I can't use HTMLBody since it doesn't have range object to select the mailbody text.

    Please Note

    Also if i try the below code in my code, i am not getting the auto intellisense error as your document is being protected and i am getting the error as "Property or indexer 'Microsoft.Interop.Word.Docment.ProtectionType' cannot be assigned to -- it is read only."

    So it means, the document is readonly rather than protected. Since the doucment is not protected document.unprotect()throws error as per the method's description. Kindly advice.

         
       if (document.ProtectionType != Microsoft.Office.Interop.Word.WdProtectionType.wdNoProtection)                {                    document.ProtectionType = Microsoft.Office.Interop.Word.WdProtectionType.wdNoProtection;                }


    http://www.selvaonline.com - Live a Happy & Balanced Life



    • Edited by SelvaOnline Wednesday, March 12, 2014 9:18 PM
    Wednesday, March 12, 2014 8:34 PM
  • I didn't suggest to use the HTMLBody property instead of WordEditor. I have just asked you to try it out, to check whether you get any exceptions or error in that case.
    Wednesday, March 12, 2014 9:10 PM
  • Hi Selva,

    Have you fixed this issue? Any updates?


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, March 18, 2014 11:54 AM
    Moderator
  • Hi Fei,

    I am converting the mailBodyformat from Plain Text to Rich Text and inserting the hyperlink and fulfilling my needs. 

    Still i am not able to add hyperlinks on the received plain text email :(

    Regards,

    Selva


    http://www.selvaonline.com - Live a Happy & Balanced Life


    • Edited by SelvaOnline Tuesday, March 18, 2014 3:12 PM
    Tuesday, March 18, 2014 3:11 PM
  • Selva,

    I've tried to ask you only one simple question: 

    Does the HTMLBody property allow to insert hyperlinks on the problematic PC? Or the issue is related to the Word editor only? Did you have a chance to test the HTMLBody property at all?

    Tuesday, March 18, 2014 6:02 PM
  • Yes. Even html body is not working with Plain text.

    I apologize for reply to your question in late :(



    http://www.selvaonline.com - Live a Happy & Balanced Life

    Tuesday, March 18, 2014 6:07 PM
  • Hi Selva,

    We can't add hyperlinks if emails are plain text format. This is by designed.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by SelvaOnline Wednesday, March 19, 2014 1:01 PM
    Wednesday, March 19, 2014 7:20 AM
    Moderator
  • Fei,

    But few messages ago you stated that it works on your machine. How is it possible?

    Wednesday, March 19, 2014 7:40 AM
  • Selva,

    Well, it confirms my assumptions.

    You need to set the BodyFormat property first to change the plain text message to the html one. Then you will be able to add hyperlinks (even with the Word editor).

    • Marked as answer by SelvaOnline Wednesday, March 19, 2014 1:00 PM
    Wednesday, March 19, 2014 7:48 AM
  • Hi Eugene,

    Yes I did like that. But i can edit the received email :) after converting BodyFormat to HTML. Its look like a bug in the office. There is no security exist to the user if anyone can edit the received mail. So i have changed the plaintext format to Richtext and adding hyperlinks.

    Regards,

    Selva


    http://www.selvaonline.com - Live a Happy & Balanced Life

    • Marked as answer by SelvaOnline Wednesday, March 19, 2014 1:00 PM
    Wednesday, March 19, 2014 11:22 AM
  • That is the right solution.
    Wednesday, March 19, 2014 12:31 PM