none
InlineResponse email body disappears on programmatic attachment add RRS feed

  • Question

  • I am running into a problem where whenever I programmatically attach a file to an Outlook 2013 InlineResponse, any text in the response is removed and the email body is reverted to what it looked like before hitting the reply button (e.g. the email signature is removed and reply header).  I have tried tricks like setting mailItem.subject = mailItem.subject (or appending a space to the email body) and then calling mailItem.save before attaching the file(s) but it has no effect.  If I hit Ctrl+s before attaching a file it works and so I am suprised that mailItem.save() doesn't help.  I also tried delving into the Word object model but can't seem to find a workaround.  It looks like the mailItem.HTMLBody of the inline response only contains the original email body and not the reply elements.
    Tuesday, March 5, 2013 7:27 PM

Answers

  • Sorry for the delay, I was traveling.
     
    I was able to repro the problem using some simple VBA code to eliminate any managed code or interop dependencies. FWIW, here's my repro code. I just added a customization to the QAT to call the macro when some text was typed in an inline respose:
     

    Sub TestInlineResponse()

        Dim expl As Outlook.Explorer

        Dim oMail As Outlook.MailItem

        Dim oA As Outlook.Attachment

        Set expl = Application.ActiveExplorer

        Set oMail = expl.ActiveInlineResponse

        oMail.Save

        Set oA = oMail.Attachments.Add("c:\test.txt")

    End Sub

    I reported this as a bug to the Outlook product group, and referenced this forum thread. If I hear anything I'll post back here. Possibly some MS representative will also post here.
     
    And, you're correct. You don't want to have to be using a hack like SendKeys.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "mcoburn" <=?utf-8?B?bWNvYnVybg==?=> wrote in message news:ad4e94c1-578d-411a-9529-9301d536fe81...

    I found that I can use SendKeys to send a Ctrl+S to the window before attaching any files to avoid the problem.  Unfortunately, our add-in supports different languages and so I don't think this is the ultimate solution as it may stop working when international keyboards are used.

    SendKeys.SendWait("^s");


    Ken Slovak MVP - Outlook
    Thursday, March 14, 2013 5:12 PM
    Moderator
  • A bug was opened on this for the product group to triage for a possible future update. If you need a hotfix pushed through on this bug, please open a support case and reference this forum thread, and tell the support engineer who gets assigned to the case that a bug was already opened on this.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "mcoburn" <=?utf-8?B?bWNvYnVybg==?=> wrote in message news:4f02a4e4-81dd-43ba-a0a4-f70bb6c75c6a...
    Much appreciated!

    Ken Slovak MVP - Outlook
    Monday, March 18, 2013 8:33 PM
    Moderator

All replies

  • I'll tak a look at this and see what I find, but it might not be until tomorrow or at least later this afternoon.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "mcoburn" <=?utf-8?B?bWNvYnVybg==?=> wrote in message news:596ee5d2-d20c-42bc-a7a4-f33dc2e625e6...
    I am running into a problem where whenever I programmatically attach a file to an Outlook 2013 InlineResponse, any text in the response is removed and the email body is reverted to what it looked like before hitting the reply button (e.g. the email signature is removed and reply header).  I have tried tricks like setting mailItem.subject = mailItem.subject (or appending a space to the email body) and then calling mailItem.save before attaching the file(s) but it has no effect.  If I hit Ctrl+s before attaching a file it works and so I am suprised that mailItem.save() doesn't help.  I also tried delving into the Word object model but can't seem to find a workaround.  It looks like the mailItem.HTMLBody of the inline response only contains the original email body and not the reply elements.

    Ken Slovak MVP - Outlook
    Wednesday, March 6, 2013 3:57 PM
    Moderator
  • Do you have any code to illustrate what you're seeing? I did a couple of quickie tests and couldn't repro what you're describing. I need some code to replicate the problem.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "mcoburn" <=?utf-8?B?bWNvYnVybg==?=> wrote in message news:596ee5d2-d20c-42bc-a7a4-f33dc2e625e6...
    I am running into a problem where whenever I programmatically attach a file to an Outlook 2013 InlineResponse, any text in the response is removed and the email body is reverted to what it looked like before hitting the reply button (e.g. the email signature is removed and reply header).  I have tried tricks like setting mailItem.subject = mailItem.subject (or appending a space to the email body) and then calling mailItem.save before attaching the file(s) but it has no effect.  If I hit Ctrl+s before attaching a file it works and so I am suprised that mailItem.save() doesn't help.  I also tried delving into the Word object model but can't seem to find a workaround.  It looks like the mailItem.HTMLBody of the inline response only contains the original email body and not the reply elements.

    Ken Slovak MVP - Outlook
    Thursday, March 7, 2013 7:56 PM
    Moderator
  • Yes, thanks for your time.  Using VS 2012 create a sample Outlook 2013 add-in targeting .NET Framework 4.0.  Create an explorer ribbon button with the following event handler.  Click "reply" on an email so that you are given an inline response for composing the reply message from the explorer window reading pane instead of a separate window.  Try typing some text in the email body (or just have a signature defined) and then try clicking your ribbon button.  Notice that any text you typed beforehand and the signature if it was provided as well as the From, Sent, To, and Subject headers are removed from the email body.  I am using Outlook 2013 (15.0.4420.1017) 64-bit.

    private void btnAttachFile_Click(object sender, RibbonControlEventArgs e)
    {
    object window = e.Control.Context;

    var explorer = window as Outlook.Explorer;

    if (explorer != null)
    {
    var mailItem = explorer.ActiveInlineResponse as Outlook.MailItem;

    if (mailItem != null)
    {
    mailItem.Attachments.Add(@"c:\temp\test.txt");
    }
    }
    }

     
    Thursday, March 7, 2013 8:15 PM
  • I found that I can use SendKeys to send a Ctrl+S to the window before attaching any files to avoid the problem.  Unfortunately, our add-in supports different languages and so I don't think this is the ultimate solution as it may stop working when international keyboards are used.

    SendKeys.SendWait("^s");

    Monday, March 11, 2013 4:56 PM
  • Sorry for the delay, I was traveling.
     
    I was able to repro the problem using some simple VBA code to eliminate any managed code or interop dependencies. FWIW, here's my repro code. I just added a customization to the QAT to call the macro when some text was typed in an inline respose:
     

    Sub TestInlineResponse()

        Dim expl As Outlook.Explorer

        Dim oMail As Outlook.MailItem

        Dim oA As Outlook.Attachment

        Set expl = Application.ActiveExplorer

        Set oMail = expl.ActiveInlineResponse

        oMail.Save

        Set oA = oMail.Attachments.Add("c:\test.txt")

    End Sub

    I reported this as a bug to the Outlook product group, and referenced this forum thread. If I hear anything I'll post back here. Possibly some MS representative will also post here.
     
    And, you're correct. You don't want to have to be using a hack like SendKeys.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "mcoburn" <=?utf-8?B?bWNvYnVybg==?=> wrote in message news:ad4e94c1-578d-411a-9529-9301d536fe81...

    I found that I can use SendKeys to send a Ctrl+S to the window before attaching any files to avoid the problem.  Unfortunately, our add-in supports different languages and so I don't think this is the ultimate solution as it may stop working when international keyboards are used.

    SendKeys.SendWait("^s");


    Ken Slovak MVP - Outlook
    Thursday, March 14, 2013 5:12 PM
    Moderator
  • Much appreciated!
    Friday, March 15, 2013 4:19 PM
  • A bug was opened on this for the product group to triage for a possible future update. If you need a hotfix pushed through on this bug, please open a support case and reference this forum thread, and tell the support engineer who gets assigned to the case that a bug was already opened on this.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "mcoburn" <=?utf-8?B?bWNvYnVybg==?=> wrote in message news:4f02a4e4-81dd-43ba-a0a4-f70bb6c75c6a...
    Much appreciated!

    Ken Slovak MVP - Outlook
    Monday, March 18, 2013 8:33 PM
    Moderator
  • Any news about this issue? Is it fixed be OL developers? Need any update with fix or relevant workaround, could you help?
    Friday, July 26, 2013 10:21 AM
  • I submitted a support ticket with Microsoft and they stated that the fix is currently scheduled for the September rollup.  They didn't mention exactly which day in September.

    Friday, July 26, 2013 3:53 PM
  • Any suggestions about workaround?
    Monday, July 29, 2013 9:27 AM
  • Wait for the September roll-up, or use the SendKeys hack mentioned in this thread. I don't know of any other workarounds.


    Ken Slovak MVP - Outlook

    Monday, July 29, 2013 1:46 PM
    Moderator