A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

C# inserting word document with formatting into outlook message



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 30th 09, 11:41 PM posted to microsoft.public.outlook.program_addins
Huginson
external usenet poster
 
Posts: 1
Default C# inserting word document with formatting into outlook message

Hi

I have been trying for days now to create a solution for this. The problem
is i have found some code examples on the web, but none of them has worked so
far. Maybe i'm missing a reference when trying them i don't know (altho i
have tried most references ). I have tried myself and also used msdn trying
examples, tho it seems to me they put out examples for everything in outlook
but the basic function of the program like working with mail messages and
interacting Oulook with other office products. Maybe i lack some basic
understanding, however i tried to read everything i could come across for
this.

This is the scenario:
I am using Visual Studio 2008
Office 2007
I am making an Outlook ribbon where the user on editing in a oulook message,
pick a word document from a dropdown in the Outlook ribbon and then i want
the word document to be inserted where the user has hers/his cursor before
going to the dropdown menu.

I have made the same function for word: there i used this code and it works
just as i want to

Word.Range currentRange = Globals.ThisAddIn.Application.Selection.Range;

object missing = System.Type.Missing;

currentRange.InsertFile(workindirectory +
"\\" + fname, ref missing, ref missing, ref missing, ref missing);


However this does not work for Oulook.

On my search i have encountered alot of people trying to find out the same
thing. Seems to me alot of folks want to use word documents for some kind of
standard template they can put into their email messages when replying to
customers etc. However most examples i have found use fully automated
answers. With office Ribbon that is not what you would normally want. The
ribbon is there for a person to click Besides you don't want to create a
new mail. You would want the word document to be inserted into the mail the
user is working on.

The closest i have come in my search are the Inspector.WordEditor; in the
documentation it says this should put a word document at the users cursor.
I have yet to find a C# example of this that actually works. And the
documentation i have found for WordEditor is...well not very friendly

Anyone that can help me here. Like i said i tried for days with 10-12 each
day searching for it and im getting a bit frustrated.

Thanks


--
Huginson
Ads
  #2  
Old August 31st 09, 03:06 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default C# inserting word document with formatting into outlook message

In Outlook 2007 there is only the Word editor and Inspector.WordEditor is a
Word Document object. It's a weak object reference for the Inspector that
you get in the Inspectors.NewInspector() event, so you are best off
instantiating an Inspector object in that event handler and subscribing to
the Inspector.Activate() event for the Inspector. In the first Activate()
event you can get WordEditor and cast it to a Word.Document object. Pretty
simple really.

There are C# examples for at least getting to WordEditor lots of places, for
example at www.outlookcode.com. I have VS 2005 templates, including C#, that
show how to handle up to the Inspector.Activate() event, from there all you
need it this before you descend into the Word object model:

Word.Document doc = (Word.Document)insp.WordEditor;

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Huginson" wrote in message
...
Hi

I have been trying for days now to create a solution for this. The problem
is i have found some code examples on the web, but none of them has worked
so
far. Maybe i'm missing a reference when trying them i don't know (altho i
have tried most references ). I have tried myself and also used msdn
trying
examples, tho it seems to me they put out examples for everything in
outlook
but the basic function of the program like working with mail messages and
interacting Oulook with other office products. Maybe i lack some basic
understanding, however i tried to read everything i could come across for
this.

This is the scenario:
I am using Visual Studio 2008
Office 2007
I am making an Outlook ribbon where the user on editing in a oulook
message,
pick a word document from a dropdown in the Outlook ribbon and then i want
the word document to be inserted where the user has hers/his cursor before
going to the dropdown menu.

I have made the same function for word: there i used this code and it
works
just as i want to

Word.Range currentRange = Globals.ThisAddIn.Application.Selection.Range;

object missing = System.Type.Missing;

currentRange.InsertFile(workindirectory +
"\\" + fname, ref missing, ref missing, ref missing, ref missing);


However this does not work for Oulook.

On my search i have encountered alot of people trying to find out the same
thing. Seems to me alot of folks want to use word documents for some kind
of
standard template they can put into their email messages when replying to
customers etc. However most examples i have found use fully automated
answers. With office Ribbon that is not what you would normally want. The
ribbon is there for a person to click Besides you don't want to create
a
new mail. You would want the word document to be inserted into the mail
the
user is working on.

The closest i have come in my search are the Inspector.WordEditor; in the
documentation it says this should put a word document at the users cursor.
I have yet to find a C# example of this that actually works. And the
documentation i have found for WordEditor is...well not very friendly

Anyone that can help me here. Like i said i tried for days with 10-12 each
day searching for it and im getting a bit frustrated.

Thanks


--
Huginson


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieve document variable from attached Word document Gordon Filby Outlook and VBA 1 September 29th 08 12:30 PM
Inserting a link to a Lotus Notes document Maria Nocera[_2_] Outlook - General Queries 3 June 10th 08 06:50 PM
Outlook 2003 save active message as Word Document Maxx[_2_] Outlook and VBA 1 April 15th 08 02:29 PM
How do I send a shortcut to a word document in an e-mail message? Rich Romeo Outlook - Using Contacts 1 July 9th 07 04:34 PM
Inserting Contact Information into a Word document HALinNY Outlook - Using Contacts 1 March 28th 07 03:18 AM


All times are GMT +1. The time now is 05:59 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.