none
Problem with Outlook 2007 trying to work with HTMLBody Property RRS feed

  • Question

  • Hello,

    I have a custom add-in /toolbar that allows a user to insert an email template (prewritten block of text) into a new email message.  What the addin does is copy what is currently in the HTMLBody of the email insert the new text then append the existing text (signature) to the end of the message.

    I have written the addin for 2010 and it works perfectly however, I am trying to use the addin also in Outlook 2007.  I have built a new solution for the 2007 addin however whenever I attempt to do anything with the HTMLBody object of the email message Outlook just hangs.  There are no error messages, If I press Alt-F4 I can then close the mail message and everything appears to continue to work.

    Here is the sequence of events:

    1. User opens a new email message and clicks a button on the toolbar.

    2. Form opens for user to select text they want inserted into the email message

    3. The code tries to set a string CurentTextvariable  = mailmessage.HTMLBody;

    4. retrieve the text from the network, insert into mailmessage and a append previous text.

    5 close the form.

    The process stops at #3.

    In the code anytime I try to do anything with the HTMLBody the application hangs, such as:

    Messagebox.Show(MailMessage.HTMLBody.ToString())

    Messagebox.Show(MailMessge.HTMLBody.Length.ToString())

    however, the command MailMessage.HTMLBody = "This is a <b>Test</b>" works.

    if anyone has any insight into what may be happening, it would be greatly appreciated.

    Wednesday, June 8, 2011 1:08 PM

Answers

  • If you developed on a machine with Office 2010 installed you would need to use Framework 4 and embed the PIA's for Outlook and Office in your application. This would have to be with VS 2010 and the latest version of VSTO. Otherwise you need to develop on a machine with the oldest version of Outlook you intend to support on the machine.
     
    If that's not the problem then it sounds like the issue might be a trust issue. It appears that attempts to read HTMLBody are failing, and that can be a security issue. Does that 2007 machine have anti-virus software that's up to date? Do you use the trusted Application object passed to you by VSTO and not create your own Outlook.Application object? All your Outlook objects need to be derived from that trusted Application object.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Paul Snow" <=?utf-8?B?UGF1bCBTbm93?=> wrote in message news:35100dce-c29b-403e-a513-b4408f47d5ac...

    Hello,

    I have a custom add-in /toolbar that allows a user to insert an email template (prewritten block of text) into a new email message.  What the addin does is copy what is currently in the HTMLBody of the email insert the new text then append the existing text (signature) to the end of the message.

    I have written the addin for 2010 and it works perfectly however, I am trying to use the addin also in Outlook 2007.  I have built a new solution for the 2007 addin however whenever I attempt to do anything with the HTMLBody object of the email message Outlook just hangs.  There are no error messages, If I press Alt-F4 I can then close the mail message and everything appears to continue to work.

    Here is the sequence of events:

    1. User opens a new email message and clicks a button on the toolbar.

    2. Form opens for user to select text they want inserted into the email message

    3. The code tries to set a string CurentTextvariable  = mailmessage.HTMLBody;

    4. retrieve the text from the network, insert into mailmessage and a append previous text.

    5 close the form.

    The process stops at #3.

    In the code anytime I try to do anything with the HTMLBody the application hangs, such as:

    Messagebox.Show(MailMessage.HTMLBody.ToString())

    Messagebox.Show(MailMessge.HTMLBody.Length.ToString())

    however, the command MailMessage.HTMLBody = "This is a <b>Test</b>" works.

    if anyone has any insight into what may be happening, it would be greatly appreciated.


    Ken Slovak MVP - Outlook
    • Marked as answer by Paul Snow Wednesday, June 8, 2011 5:18 PM
    Wednesday, June 8, 2011 2:29 PM

All replies

  • If you developed on a machine with Office 2010 installed you would need to use Framework 4 and embed the PIA's for Outlook and Office in your application. This would have to be with VS 2010 and the latest version of VSTO. Otherwise you need to develop on a machine with the oldest version of Outlook you intend to support on the machine.
     
    If that's not the problem then it sounds like the issue might be a trust issue. It appears that attempts to read HTMLBody are failing, and that can be a security issue. Does that 2007 machine have anti-virus software that's up to date? Do you use the trusted Application object passed to you by VSTO and not create your own Outlook.Application object? All your Outlook objects need to be derived from that trusted Application object.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Paul Snow" <=?utf-8?B?UGF1bCBTbm93?=> wrote in message news:35100dce-c29b-403e-a513-b4408f47d5ac...

    Hello,

    I have a custom add-in /toolbar that allows a user to insert an email template (prewritten block of text) into a new email message.  What the addin does is copy what is currently in the HTMLBody of the email insert the new text then append the existing text (signature) to the end of the message.

    I have written the addin for 2010 and it works perfectly however, I am trying to use the addin also in Outlook 2007.  I have built a new solution for the 2007 addin however whenever I attempt to do anything with the HTMLBody object of the email message Outlook just hangs.  There are no error messages, If I press Alt-F4 I can then close the mail message and everything appears to continue to work.

    Here is the sequence of events:

    1. User opens a new email message and clicks a button on the toolbar.

    2. Form opens for user to select text they want inserted into the email message

    3. The code tries to set a string CurentTextvariable  = mailmessage.HTMLBody;

    4. retrieve the text from the network, insert into mailmessage and a append previous text.

    5 close the form.

    The process stops at #3.

    In the code anytime I try to do anything with the HTMLBody the application hangs, such as:

    Messagebox.Show(MailMessage.HTMLBody.ToString())

    Messagebox.Show(MailMessge.HTMLBody.Length.ToString())

    however, the command MailMessage.HTMLBody = "This is a <b>Test</b>" works.

    if anyone has any insight into what may be happening, it would be greatly appreciated.


    Ken Slovak MVP - Outlook
    • Marked as answer by Paul Snow Wednesday, June 8, 2011 5:18 PM
    Wednesday, June 8, 2011 2:29 PM
  • Thank you,

    It was a security issue.  Once I used the trusted Application object everything worked.

     

    Paul.

    Wednesday, June 8, 2011 5:19 PM