PC Review


Reply
Thread Tools Rate Thread

C# inserting word document with formatting into outlook message

 
 
Huginson
Guest
Posts: n/a
 
      30th Aug 2009
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
 
Reply With Quote
 
 
 
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      31st Aug 2009
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" <(E-Mail Removed)> wrote in message
news:AD6A2984-A50D-477E-98E4-(E-Mail Removed)...
> 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


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting a Word document into Outlook =?Utf-8?B?ZWNvbW1tZWRpY2luZQ==?= Microsoft Outlook Discussion 0 29th Jan 2007 07:18 PM
OLE Automation: Use word document with its formatting in body message papou Microsoft Outlook VBA Programming 1 31st Dec 2004 02:40 PM
I am inserting a word document in an e-mail and the formatting ch. =?Utf-8?B?TWVs?= Microsoft Outlook Discussion 1 17th Dec 2004 02:49 PM
Inserting an email message into a word document =?Utf-8?B?c3R1YXJ0IGNoYWxtZXI=?= Microsoft Word Document Management 3 3rd Feb 2004 05:49 AM
Inserting a Word document as the body of an email message Susy Microsoft Outlook Discussion 1 30th Dec 2003 12:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:39 AM.