how to copy the text from textbox and paste on outlook message body

1.4k views Asked by At

I tried to develop an Outlook add-in to ask users for information by showing a Windows Form with several TextBox controls. The text (includes name, phone, email address etc) user input will be added in the Outlook mail body as signature.

Just wonder that how can I get all the data user entered and paste them on the Outlook mail body? Can i just copy them all on the clipboard and paste into the body? Still cannot find a proper method to achieve this, could you give me some suggestions?

1

There are 1 answers

0
Eugene Astafiev On

You can defined public methods and properties on your Windows form for getting the values an user entered.

The Outlook object model provides three main ways for working item bodies:

  1. Body - a string representing the clear-text body of the Outlook item.
  2. HTMLBody - a string representing the HTML body of the specified item.
  3. Word editor - the Microsoft Word Document Object Model of the message being displayed. The WordEditor property of the Inspector class returns an instance of the Document class from the Word object model which you can use to set up the message body.

You can read more about all these ways in the Chapter 17: Working with Item Bodies. It us up to you which way is to choose to customize the signature in the message body.

To get the active inspector window use the ActiveInspector method of the Application class. The method returns the topmost Inspector object on the desktop. The CurrentItem property returns an Object (it will be a mail item in your case) representing the current item being displayed in the inspector.