Reader Level:
ARTICLE

Office automation with VS 2008

Posted by kohad Articles | .NET Remoting March 17, 2009
Outlook automation has become integral part of any LOB application. MS Excel, work, outlook are getting used by most of the enterprise applications today. This article provides quick view on how to integrate outlook with .net application
  • 0
  • 0
  • 11513
Download Files:
 

Introduction

Outlook automation has become integral part of any LOB application. MS Excel, work, outlook are getting used by most of the enterprise applications today. This article provides quick view on how to integrate outlook with .net application.

In this example we will create a button in outlook on click of that button it will execute a method in an application.
Steps to create outlook project:

  1. Click on new project.
  2. Select "Office" as project type
  3. Select "Office 2007 Add in" template from right side pane.
  4. Enter name of the addin and path for the project; click on Ok
  5. Visual Studio will create "ThisAddIn.cs" file for you.
  6. Write below code snippet in the ThisAddIn_Startup.

    a. Generate command bar.



    b. Generate command button.

Steps to create .net Application

  1. Open Visual Studio. Click on File->New->Project
  2. Select Windows from left pane.
  3. Select Windows Forms application from right pane.
  4. Enter name and location of project
  5. Click on Ok.
  6. Below code snippet shows how to create remotable object.

    a. Code snippet for IRemoteObject



    b. Code snippet for RemoteObject


     
  7. Below code snippet show how to create remote server to listen request from outlook


     
  8. Add a new window form with a button in the same project. Set caption of the form as Server and button caption as "Start Server".
     
  9. In the button click write below code.

Steps to integrate with .net application

  1. In ThisAddin.cs file we created defination for _myButton _Click. Write below lines of code in the defination.

Steps to install Outlook application

  1. In the same instance of Visual Studio of outlook project. Click on File->New->Project
  2. Select "Setup and Deployment" under "Other Project Type" from left pane.
  3. Select "Setup Project" from right pane.
  4. In "File System Editor" select "Application folder" from left pane.
  5. Right click on "Application folder" and select Add->Project Output.
  6. In the "Add Project Output group" window select Outlook project.
  7. Select "Primary Output" from below list box.
  8. Click on Ok
  9. Outlook project output and related dependent files will get added in the Application folder.
  10. Build the setup project.
  11. Navigate to the output folder of the setup project and run setup.exe
  12. After the completion of setup start MS Outlook
  13. You must see button gets added in the tool bar.

Now run your windows form application and start server by clicking on the "Start Server" button.

Click "Click Me" button on MS Outlook , you must get message "Call from outlook".

COMMENT USING

Trending up