none
ArgumentException while setting MailItem.HTMLBody RRS feed

  • Question

  • Hi,

    we have a support case with an ArgumentException, while setting the HTMLBody of a MailItem. Here are the circumstances:

    Our Add-In decrypts an OpenPGP-encrypted PGP/MIME mail. It has an attachment called encrypted.asc, which contains an encrypted mime-mail sourcecode. Our addin creates a copy of the mail, decrypts this file and changes the mail to that, what the mime-parts inside encrpted.asc describe.

    This has worked very well in the past, but this single customer has problems with one email.

    Here the Exception:

    ERROR (Exception-Type: System.ArgumentException in set_HTMLBody):
    The operation could not be completed. At least one parameter is not valid.
       at Microsoft.Office.Interop.Outlook._MailItem.set_HTMLBody(String HTMLBody)
       at [...]

    Not very much information, but i hope, someone can tell me a bit more, than i know yet :)

    Note: We are handling the atttachments something like described here: http://stackoverflow.com/questions/4196160/vsto-outlook-embed-image-mailitem

    Kind regards,
    Daniel

    Tuesday, September 4, 2012 8:31 AM

Answers

  • After a long time today I received an email from our customer. He himself has found the solution - The option "Read email messages in plain text" was enabled. It can be found in the Trust Center of Outlook 2013 or the security settings of Outlook 2010.

    http://office.microsoft.com/en-us/outlook-help/read-email-messages-in-plain-text-HP010356474.asp

    • Marked as answer by Ranfty2000 Tuesday, April 1, 2014 9:58 AM
    Tuesday, April 1, 2014 9:57 AM

All replies

  • What is the string that you assign to the HTMLBody property?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Tuesday, September 4, 2012 4:33 PM
  • it is a well coded HTML document (generated by another mail client) - the w3c validator does only comment, that the <title> is missing.

    [edit]
    No images, just formatted text

    • Edited by Ranfty2000 Wednesday, September 5, 2012 6:55 AM
    Wednesday, September 5, 2012 6:54 AM
  • Does it always happen for a particular HTML value?

    Can you simplify it until there is no error?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Thursday, September 6, 2012 5:31 AM
  • It seems like it happened also with another mail. We can not simplify it, the error did not occour on our computers, but on a customer's one.

    We only have his log files and a decrypted copy of the "encrypted.asc" file for debugging. Also we were not able to reproduce the error.

    Thursday, September 6, 2012 6:38 AM
  • Can you get the e-mail from the customer and attempt to reproduce it in your environment?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Friday, September 7, 2012 6:35 AM
  • [...] and a decrypted copy of the "encrypted.asc" file for debugging. Also we were not able to reproduce the error.

    I have the meaningfull part of his email, but i was not able to reproduce the error...
    Friday, September 7, 2012 6:47 AM
  • Hi Ranfty2000,

    Thanks for posting in the MSDN Forum.

    It's based on my experience that the exception occurs due to the set_HTMLBody() is not a valid method in your scenario. Can you try to set the MailItem.HTMLBody like this http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/97c157a0-06b8-4079-a5a6-a9d6887ec562/

    Hope it helps.

    Regards,


    Leo_Gao [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, September 11, 2012 5:37 AM
    Moderator
  • Hi again,

    after some months we released an update of our product, which hopefully would solve the problem. But no, it didn't, the exception is still appearing.

    To your questtion Leo_Gao

    It's based on my experience that the exception occurs due to the set_HTMLBody() is not a valid method in your scenario. Can you try to set the MailItem.HTMLBody like[...]

    As you can read in the initial message of mine, i use the set of the HTMLBody property, which is in fact a method with the "set_" prefix.

    Can anybody tell me, why this exception is thrown?

    Friday, December 7, 2012 1:40 PM
  • After a long time today I received an email from our customer. He himself has found the solution - The option "Read email messages in plain text" was enabled. It can be found in the Trust Center of Outlook 2013 or the security settings of Outlook 2010.

    http://office.microsoft.com/en-us/outlook-help/read-email-messages-in-plain-text-HP010356474.asp

    • Marked as answer by Ranfty2000 Tuesday, April 1, 2014 9:58 AM
    Tuesday, April 1, 2014 9:57 AM