C# inserting word document with formatting into outlook message

Status
Not open for further replies.
H

Huginson

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
 
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;

"Huginson" <Huginson> wrote in message

news:AD6A2984-A50D-477E-98E4-DF7AAFF8BA6C@microsoft.com...
> 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
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Witzker Pls help to change the code for inserting date in Ol contact body Outlook VBA and Custom Forms 5
D Inserting sender name and address with vba Outlook VBA and Custom Forms 1
W Inserting Additional Email Address Outlook VBA and Custom Forms 4
G Message template / custom forms and VBA Help needed - inserting info into table Outlook VBA and Custom Forms 3
D Using Libraries when inserting a file in Outlook 2013 Using Outlook 1
L Inserting a PPT/PDF into the message body Using Outlook 1
B Outlook 2007 - Slow opening folders when inserting attachments Using Outlook 2
S Inserting Dates With Quick Parts (or Macros) Using Outlook 4
L Block others from inserting appointments in your calendar Using Outlook 3
W inserting activeX/user control into form Outlook VBA and Custom Forms 1
R Inserting a hyperlink in the bod of an outlook appt. Outlook VBA and Custom Forms 13
K Inserting text from a macro Outlook VBA and Custom Forms 1
S Outlook 2021 Can you make emails from 3 word domains "safe" by entering top 2 word domain into Safe List in Outlook? Using Outlook 1
O How to find and replace a word in Outlook-Agenda-Subject and Message? Using Outlook 0
V Embedding hyperlink into Word document Using Outlook 2
glnz Can Word Normal.dotm interfere with Outlook? Office 2016 Using Outlook 5
S Outlook Macro to move reply mail based on the key word in the subjectline Outlook VBA and Custom Forms 0
C blocking two or more word domains separated by period/dot Using Outlook 3
P Outlook 2013 Word Share doc as Email Attachment now brings up Eudora. Using Outlook 1
Jennifer Murphy Ctrl+Tab sometimes will not move through text a word at a time Using Outlook 1
N How to remove signature formatting from Text in Word (accidentally taken from Outlook) Using Outlook 0
C replace subject line generated by converting a word document to PDF and sending it to an email Using Outlook 8
Diane Poremsky Use Word Macro to Apply Formatting to Email Using Outlook 0
iwshim word shortcut to search outlook Using Outlook 3
C Outlook 2016 - converting Word VBA to default Outlook message Outlook VBA and Custom Forms 0
C Merging Word and Access into Outlook Using Outlook 4
Q Why can't I copy image with embedded hyperlink from email to Word Using Outlook 0
Mark Foley Emailing attachment from Word/Excel sends attachment but no message body Using Outlook 0
Diane Poremsky Disable Live Preview in Outlook and Word Using Outlook 0
Philip Rose Recreating a WORD Editing Macro to use in Outlook VBA Outlook VBA and Custom Forms 4
D Need to extract a line from a word attachment, and add it to the subject line Outlook VBA and Custom Forms 3
M Unable to email from Word or Excel Using Outlook 11
P Macros in Word 2003 - how to transfer to another Word 2003? Using Outlook 1
J VBS Script (macro) for word to open Outlook template. Outlook VBA and Custom Forms 2
B Outlook to Word Template error Using Outlook 4
J Outlook body to word document Outlook VBA and Custom Forms 11
A Is it possible to remove the word Categories: from task list views? Using Outlook 2
A Application_ItemSend not accessed when sending email outside outlook (i.e. word or send to mail from Using Outlook 7
W Macro to add a word in Subject Line Using Outlook 1
O Copy email content and paste into new Word Document using a different font Using Outlook 1
K Import 2013 Outlook Contact Address into Word Using Outlook 36
J "Specific word in body" question Using Outlook 1
D opening Word Document in a business contact? BCM (Business Contact Manager) 3
Z Send mail and contents of body from ms word document Using Outlook 1
O Choosing Sending Email Address from Word Using Outlook 5
C Printing Outlook Form Controls via Word Using Outlook 11
S Highlighter colors limited in Outlook 2007 and Word 2007 Using Outlook 1
L Macro to Open a Specific Word Document - Outlook 2007 Using Outlook 17
O Outlook 2010 does not open MS Word attachments Using Outlook 1
R Using Word/OL 2010 to generate personalized email messages Using Outlook 1

Similar threads

Back
Top