Git Product home page Git Product logo

outlook-add-in-javascript-getattachments's Introduction

page_type products languages description extensions
sample
office-outlook
office-365
javascript
This sample shows you how to get attachments from an Exchange mailbox.
contentType technologies createdDate
samples
Add-ins
8/11/2015 1:48:02 PM

Outlook add-in: Get attachments from an Exchange server

Table of contents

##Summary This sample shows you how to get attachments from an Exchange mailbox.

Prerequisites

This sample requires the following:

  • Visual Studio 2013 with Update 5 or Visual Studio 2015.
  • A computer running Exchange 2013 with at least one email account, or an Office 365 account. You can join the Office 365 Developer Program and get a free 1 year subscription to Office 365.
  • Any browser that supports ECMAScript 5.1, HTML5, and CSS3, such as Internet Explorer 9, Chrome 13, Firefox 5, Safari 5.0.6, or a later version of these browsers.
  • Familiarity with JavaScript programming and web services.

Key components of the sample

The sample solution contains the following files:

  • AttachmentExampleManifest.xml: The manifest file for the Outlook add-in.
  • AppRead\Home\Home.html: The HTML user interface for the mail add-in for Outlook.
  • AppRead\Home\Home.js: The JavaScript file that handles sending the attachment information to the remote Attachment service included with this sample.

The AttachmentService project defines a REST service by using the WCF API. The project contains the following files:

  • Controllers\AttachmentServiceController.cs: The service object that provides the business logic for the sample service.
  • Models\ServiceRequest: The object that represents a web request. The contents of the object are created from a JSON request object sent from your mail add-in.
  • Models\Attachment.cs: The utility object that helps deserialize the JSON object that is sent by the mail add-in.
  • Models\AttachmentDetails.cs: The object that represents the details of each attachment. It provides a .NET Framework object that matches the mail add-in's AttachmentDetails object.
  • Models\ServiceResponse: The object that represents a response from the web service. The contents of the object are serialized to a JSON object when they are sent back to the mail add-in.
  • Web.config: Binds the sample service to the web server endpoint.

##Description of the code

This sample shows you how to retrieve attachments from a web service that supports your mail add-in. For example, you can create a service that uploads photos to a sharing site, or a service that stores documents into a repository. The service gets the attachments directly from the Exchange server, and doesn't require the client to perform extra processing to get the attachment and then send it along to the service.

The sample has two parts. The first part, the mail app, runs in the email client. The mail add-in is shown whenever a message or an appointment is the active item. When you select the Test attachments button, the mail add-in sends details about the attachment to the web service that processes the request. The service uses the following steps to process attachments:

  • Sends a GetAttachment operation request to the Exchange server that hosts the mailbox. The server responds by sending the attachment to the service. In this sample, the service simply writes the XML from the server to trace output.
  • Returns the number of attachments processed to the mail app.

Build and debug

Note: The mail add-in will be activated on any email message in the user's Inbox that has one or more attachments. You can make it easier to test the add-in by sending one or more email messages to your test account before you run the sample add-in.

  1. Open the solution in Visual Studio.
  2. Right-click the solution in Solution Explorer. Select Set Startup Projects.
  3. Select Common Properties, and choose Startup Project.
  4. Make sure that the Action for AttachmentExampleService project is set to Start.
  5. Press F5 to build and deploy the sample add-in.
  6. Connect to an Exchange account by providing the email address and password for an Exchange 2013 server.
  7. Allow the server to configure the mail account.
  8. Log on to the email account by entering the account name and password.
  9. Select a message in the Inbox.
  10. Wait for the add-in bar to appear over the message.
  11. In the add-in bar, click AttachmentExample.
  12. When the mail add-in appears, click the TestAttachments button to send a request to the Exchange server.
  13. The server will respond with the number of attachments processed for the item. This should equal the number of attachments that the item contains.

##Troubleshooting The following are common errors that can occur when you use Outlook Web App to test a mail add-in for Outlook:

  • The add-in bar does not appear when a message is selected. If this occurs, restart the application by selecting Debug – Stop Debugging in the Visual Studio window, then press F5 to rebuild and deploy the add-in.
  • Changes to the JavaScript code may not be picked up when you deploy and run the add-in. If the changes are not picked up, clear the cache on the web browser by selecting Tools – Internet options and clicking the Delete… button. Delete the temporary Internet files and then restart the add-in.

##Questions and comments##

  • If you have any trouble running this sample, please log an issue.
  • Questions about Office Add-in development in general should be posted to Stack Overflow. Make sure that your questions or comments are tagged with [office-addins].

Additional resources

Copyright

Copyright (c) 2015 Microsoft. All rights reserved.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

outlook-add-in-javascript-getattachments's People

Contributors

davidchesnut avatar dependabot[bot] avatar eloekset avatar jamescro avatar lindalu-msft avatar mimisasouvanh avatar nokafor avatar o365devx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.