Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Message.displayReplyForm method (JavaScript API for Office)

Office Add-ins

Displays a reply form that includes only the sender of the selected message.

Last modified: July 06, 2015

Note Note

The name "apps for Office" is changing to "Office Add-ins". During the transition, the documentation and the UI of some Office host applications and Visual Studio tools might still use the term "apps for Office". For details, see New name for apps for Office and SharePoint.

Hosts:Outlook

App type: Mail

Available in requirement sets

Mailbox

Last changed in Mailbox

1.0

Applicable Outlook modes

Read

See all support details

Office.context.mailbox.item.displayReplyForm(htmlBody)
Office.context.mailbox.item.displayReplyForm( {"body": "...", "attachments":"[ { "type": "item", "id":"..."}, { "type":"file", "name":"...", "url"""..." } ], "callback": "..."  } ) )

htmlBody

A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB.

"body"

Optional. For the method override. A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB. If this is used, don't use the "attachments" parameter.

"attachments"

Optional. For the method override. An array of JSON objects which are either file or item attachments. If this is used, don't use the "body" parameter.

A file attachment JSON is defined as follows:

{
    "type":"file",
    "name":"...",
    "url":"..."
}

"type"

Required. Must be "file" for file attachments.

"name"

Required. A string name of the attachment, up to 255 characters in length.

"url"

Required. The URI of the location for the file bytes.

An item attachment JSON is defined as follows:

{
    "type":"item",
    "id":"..."
}

"type"

Required. Must be "item" for item attachments.

"id"

Required. The EWS item id of the attachment. This is a string up to 100 characters in length.

callback

Optional. For the override method. The function that is called when the request is completed.

In Outlook Web App, the reply form is displayed as a pop-out form in the 3-column view and a pop-up form in the 2- or 1-column view.

If htmlBody exceeds the 32-KB limit, displayReplyForm throws an exception.

The method override accepts a JSON object as described in the parameter section. When the override method is invoked, Outlook and Outlook Web App attempt to download all attachments and attach them to the reply form. If any attachments fail to be added, an error is shown in the form UI. If this isn't possible, then no error message is thrown.

The method override throws an exception:

  • If the value for "body" exceeds the 32-KB limit

  • If the URI exceeds 2048 characters

  • If the attachment id exceeds 100 characters

  • If the attachment name exceeds 255 characters

  • If the number of attachments exceeds the limit, a NumberOfAttachmentsExceeded error is returned.

The following code example in JavaScript obtains the selected item, checks if the item is a message, and displays a reply form to the sender.

var myOm;
var myItem;

// Initialize runtime.
// The initialize function is required for all apps.
Office.initialize = function () {
    myOm = Office.context.mailbox;
    // Get the selected item.
    myItem = myOm.item;

    // Checks for the DOM to load using the jQuery ready function.
    $(document).ready(function () {
        // After the DOM is loaded, app-specific code can run.
        displayReply();
    });
}

function displayReply()
{
    // Display a reply form to the sender only 
    // if the selected item is a message.
    if (myitem.itemType == Office.MailboxEnums.ItemType.Message)
    {
        myItem.displayReplyForm
        ("<html><head><head><body>This is the body of the email reply.</body></html>");
    }
}

A checkmark (√) in the following table indicates that this property is supported in the corresponding Outlook host application. An empty cell indicates that the Outlook host application doesn't support this property.

For more information about Office host application and server requirements, see Requirements for running apps for Office.

Supported hosts, by platform

Office for Windows desktop

Office Online
(in browser)

OWA for Devices

Office for Mac

Outlook

√ (Read mode only)

Available in requirement sets

Mailbox

Minimum permission level

ReadItem

App types

Mail

Library

Office.js

Namespace

Office

Version

Changes

1.0

Introduced

Show:
© 2015 Microsoft