Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook - Using Forms (http://www.outlookbanter.com/outlook-using-forms/)
-   -   How to get Selected Body message Text (http://www.outlookbanter.com/outlook-using-forms/94305-how-get-selected-body-message.html)

pasteface method crashing outlook[_2_] August 31st 09 10:19 AM

How to get Selected Body message Text
 
Hi,

I need to handle an event whenever we select something in mail body. Can
anyone say how to handle this event and how to get selected text.

I'm developing an outlook add-in in ATL COM(VC++)

Regards
Kiran. S

Ken Slovak - [MVP - Outlook] August 31st 09 03:13 PM

How to get Selected Body message Text
 
There is no such event in the Outlook object model. If you are using
WordMail you can get Inspector.WordEditor as a Word.Document object and use
the Word Object model for that. If you are using HTML then you would have to
use the IHTMLDocument object model.

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


"pasteface method crashing outlook"
oft.com wrote in message
...
Hi,

I need to handle an event whenever we select something in mail body. Can
anyone say how to handle this event and how to get selected text.

I'm developing an outlook add-in in ATL COM(VC++)

Regards
Kiran. S



pasteface method crashing outlook[_2_] September 9th 09 01:47 PM

How to get Selected Body message Text
 
Thanks Ken,

I tried Word Object Model and tried to capture the WordEditor of an mail
item. But inspector-get_WordEditor() is giving null pointer.
Code:
CComQIPtrOutlook::_Inspector spInspector;

CComPtrMSWord::_Document spWordDoc;
CComPtrMSWord::Selection spWordSelection;
CComPtrMSWord::_Application spWordApp;

spMailItem-get_GetInspector(&spInspector);
CComPtrOutlook::_Application spApp;
spInspector-get_EditorType(&editType);
BSTR str;
VARIANT_BOOL vTemp;

spInspector-IsWordMail(&vTemp);

if(vTemp == VARIANT_TRUE)
{

spInspector-get_WordEditor((IDispatch**)&spWordDoc);

spWordDoc-get_Application(&spWordApp);
spWordApp-get_Selection(&spWordSelection);
spWordSelection-get_Text(&str);
}

Please let me know if any issue found.

Regards
Kiran. S



"Ken Slovak - [MVP - Outlook]" wrote:

There is no such event in the Outlook object model. If you are using
WordMail you can get Inspector.WordEditor as a Word.Document object and use
the Word Object model for that. If you are using HTML then you would have to
use the IHTMLDocument object model.

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


"pasteface method crashing outlook"
oft.com wrote in message
...
Hi,

I need to handle an event whenever we select something in mail body. Can
anyone say how to handle this event and how to get selected text.

I'm developing an outlook add-in in ATL COM(VC++)

Regards
Kiran. S




Ken Slovak - [MVP - Outlook] September 9th 09 02:44 PM

How to get Selected Body message Text
 
Where are you calling that code?

I've seen, especially in Outlook 2007, that WordEditor is null up until the
first Inspector.Activate() event. For example it's null in
Inspectors.NewInspector() because you're only getting a weak object
reference at that point.

If there is no Inspector then obviously there can't be a WordEditor object
since there is no Inspector.

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


"pasteface method crashing outlook"
oft.com wrote in message
...
Thanks Ken,

I tried Word Object Model and tried to capture the WordEditor of an mail
item. But inspector-get_WordEditor() is giving null pointer.
Code:
CComQIPtrOutlook::_Inspector spInspector;

CComPtrMSWord::_Document spWordDoc;
CComPtrMSWord::Selection spWordSelection;
CComPtrMSWord::_Application spWordApp;

spMailItem-get_GetInspector(&spInspector);
CComPtrOutlook::_Application spApp;
spInspector-get_EditorType(&editType);
BSTR str;
VARIANT_BOOL vTemp;

spInspector-IsWordMail(&vTemp);

if(vTemp == VARIANT_TRUE)
{

spInspector-get_WordEditor((IDispatch**)&spWordDoc);

spWordDoc-get_Application(&spWordApp);
spWordApp-get_Selection(&spWordSelection);
spWordSelection-get_Text(&str);
}

Please let me know if any issue found.

Regards
Kiran. S



pasteface method crashing outlook[_2_] September 10th 09 07:04 AM

How to get Selected Body message Text
 

I'm call the code when we change mail item in main pane( BY handling
Command-Bar events). I'm able to get Inspector pointer but its WordEditor is
returning NULL. Using the below code to capture Inspector pointer.

Code:
CComPtr Outlook::SelectionspSelection;
m_pExplorer-get_Selection(&spSelection);

BSTR strname;
if(spSelection)
{

CComPtr IDispatch spItem;
CComVariant vCount(1);
spSelection-Item(vCount,&spItem);
if(!spItem)
return;
ATLASSERT(spItem);
CComQIPtr Outlook::_MailItem spMailItem(spItem);
ATLASSERT(spMailItem);

fprintf(fileptr,"[WSforOutlookMailItemSearching]-spMailItem::Success\r\n");
fflush(fileptr);

CComQIPtrOutlook::_Inspector spInspector;
spMailItem-get_GetInspector(&spInspector)
}

- Kiran. S

"Ken Slovak - [MVP - Outlook]" wrote:

Where are you calling that code?

I've seen, especially in Outlook 2007, that WordEditor is null up until the
first Inspector.Activate() event. For example it's null in
Inspectors.NewInspector() because you're only getting a weak object
reference at that point.

If there is no Inspector then obviously there can't be a WordEditor object
since there is no Inspector.

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


"pasteface method crashing outlook"
oft.com wrote in message
...
Thanks Ken,

I tried Word Object Model and tried to capture the WordEditor of an mail
item. But inspector-get_WordEditor() is giving null pointer.
Code:
CComQIPtrOutlook::_Inspector spInspector;

CComPtrMSWord::_Document spWordDoc;
CComPtrMSWord::Selection spWordSelection;
CComPtrMSWord::_Application spWordApp;

spMailItem-get_GetInspector(&spInspector);
CComPtrOutlook::_Application spApp;
spInspector-get_EditorType(&editType);
BSTR str;
VARIANT_BOOL vTemp;

spInspector-IsWordMail(&vTemp);

if(vTemp == VARIANT_TRUE)
{

spInspector-get_WordEditor((IDispatch**)&spWordDoc);

spWordDoc-get_Application(&spWordApp);
spWordApp-get_Selection(&spWordSelection);
spWordSelection-get_Text(&str);
}

Please let me know if any issue found.

Regards
Kiran. S




Ken Slovak - [MVP - Outlook] September 10th 09 02:04 PM

How to get Selected Body message Text
 
You would need to display the Inspector.

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


"pasteface method crashing outlook"
oft.com wrote in message
...

I'm call the code when we change mail item in main pane( BY handling
Command-Bar events). I'm able to get Inspector pointer but its WordEditor
is
returning NULL. Using the below code to capture Inspector pointer.

Code:
CComPtr Outlook::SelectionspSelection;
m_pExplorer-get_Selection(&spSelection);

BSTR strname;
if(spSelection)
{

CComPtr IDispatch spItem;
CComVariant vCount(1);
spSelection-Item(vCount,&spItem);
if(!spItem)
return;
ATLASSERT(spItem);
CComQIPtr Outlook::_MailItem spMailItem(spItem);
ATLASSERT(spMailItem);

fprintf(fileptr,"[WSforOutlookMailItemSearching]-spMailItem::Success\r\n");
fflush(fileptr);

CComQIPtrOutlook::_Inspector spInspector;
spMailItem-get_GetInspector(&spInspector)
}

- Kiran. S



pasteface method crashing outlook[_2_] September 11th 09 04:34 AM

How to get Selected Body message Text
 
can you tell me which event is needed to handle , when we select the text in
outlook 2007.

-Kiran.S

"Ken Slovak - [MVP - Outlook]" wrote:

You would need to display the Inspector.

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


"pasteface method crashing outlook"
oft.com wrote in message
...

I'm call the code when we change mail item in main pane( BY handling
Command-Bar events). I'm able to get Inspector pointer but its WordEditor
is
returning NULL. Using the below code to capture Inspector pointer.

Code:
CComPtr Outlook::SelectionspSelection;
m_pExplorer-get_Selection(&spSelection);

BSTR strname;
if(spSelection)
{

CComPtr IDispatch spItem;
CComVariant vCount(1);
spSelection-Item(vCount,&spItem);
if(!spItem)
return;
ATLASSERT(spItem);
CComQIPtr Outlook::_MailItem spMailItem(spItem);
ATLASSERT(spMailItem);

fprintf(fileptr,"[WSforOutlookMailItemSearching]-spMailItem::Success\r\n");
fflush(fileptr);

CComQIPtrOutlook::_Inspector spInspector;
spMailItem-get_GetInspector(&spInspector)
}

- Kiran. S




Ken Slovak - [MVP - Outlook] September 11th 09 02:35 PM

How to get Selected Body message Text
 
There is no event for that in the Outlook object model.

You'd have to open the item so it was being handled by WordMail, get
Inspector.WordEditor as a Word.Document object, then get the Parent property
of that as Word.Application and use the
Word.Application.WindowSelectionChange() event.

If the text was selected in the reading pane I don't know of a way to get an
event for that at all.

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


"pasteface method crashing outlook"
oft.com wrote in message
...
can you tell me which event is needed to handle , when we select the text
in
outlook 2007.

-Kiran.S




All times are GMT +1. The time now is 06:10 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com