Using VSTO to perform an action via selected e-mail text in Outlook - vsto

This should be pretty a pretty common scenario, but I have not found a solution yet.
I would like to highlight some text within the body of an e-mail and then click on something (context menu, toolbar button, etc) to perform a URL navigation using the selected text. For example, highlight the Fex Ex tracking number and then navigate to their web site using it as a query parameter (like "ww.fedextracking.com?packageid=12345").
How can you capture the selected text within an e-mail and then perform an action? I would greatly appreciate any suggestions or examples.
Thank you!

For Outlook 2007-2010 (or previous versions using WordMail), you can retrieve a Word object from the Inspector.WordEditor property. Then you can work with Word.Selection to access the selected text.
However, for Plain Text or Rich Text scenarios with Outlook 2000-2003, you have to use the SafeInspector object with Redemption (http://www.dimastr.com/redemption/) to access the selected text. I can't remember, but for HTML format messages with Outlook 2003-2003 you may be able to access the selected text with the IHTMLDocument object retrieved from SafeInspector.

I appreciate it's 588 days since you asked your question Loki70, but if somebody else Googles up this page (like I did, looking for how to create a selected text right-click context menu entry) then this may be an answer for you.
I have been using AutoHotKey, which works not just in Outlook, but everywhere in Windows, and have been writing utilities to Google the selected text, open an SSH session in PuTTY to the selected hostname, and similar.
If you don't mind running an extra application on your PC to capture the hotkey combination that you send, then this would do exactly what you're asking.
Here is my post on the AutoHotKey forum with a link to my code:
http://www.autohotkey.com/community/viewtopic.php?t=86402
It would be trivial to adapt this to do the FedEx query you've mentioned.
I hope this helps.

Related

How can I do find and highlight text in outlook

I am developing outlook web-Addin visual studio share point developing tool.i want to find a specific word in the document and highlight that word.
#Vishnu Kay Vee
Currently the feature you requested is not a part of the product. However, we track Outlook add-in feature requests on ourĀ user-voice page. Please add your request there. Feature requests on user-voice are considered when we go through our planning process.
[Outlook Add-ins Engineering Team]
In the email message or item you're creating, on the Format Text tab, in the Editing group, choose Find.
In the Find what box, type the text that you want to search for.
Choose Reading Highlight > Highlight All.
Note: To turn off highlighting on the screen, choose Reading Highlight > Clear Highlighting.
This link will help you about Find and replace text within an email message or item: https://support.office.com/en-us/article/find-and-replace-text-within-an-email-message-or-item-ee05a4ac-6c30-4687-8098-84f4390d2d6f

VBA MSHTML TextInput Click Failed

I've worked on multiple web-scraping projects using Excel VBA before, but I haven't encountered this problem before. I've been googling the issue for the past few hours, but I haven't found a solution yet.
Scenario:
My webpage consists of a list-box and a text box that acts as a filter/search. Unfortunately, I can't disclose the webpage information, but somewhere in the list box elements I saw the word "JQuery". After creating an HTMLInputElement, I set it to text box object and changed its value to "TEXT". I expected the list to get update, but nothing happened. I tried to use different approaches, but they all failed.
Text_Field.Focus
Text_Field.FireEvent "onclick"
Text_Field.Value = "TEXT"
Text_Field.Click
I managed to put the text in the text box, but the clicking part does not work. When I do it manually, as soon as I type the phrase into the text box, the list gets updated immediately. Any thoughts or suggestions?
I tried to simulate the "enter key" press, but it didn't work either.
Your help will be appreciated.
Best,
Arman
Event won't fire when you operate elements programmatically. you have to simulate the events too, using document.createEventObject/inputElement.fireEvent (IE8 or lower) or document.createEvent/inputElement.dispatchEvent (IE9+).
What event you need to fire depends on what the script is interested in (onkeypress, onblur, onpaste, etc).

OneNote 2016: How to: selected text in a page & subscribe to the onClick event

I want to implement a COM OneNote Add-In (for OneNote Desktop) with the following functionality:
User selects some text and then clicks the FORMAT button exposed by the add-in: the add-in will format the selected text in some specific way (e.g. surround the text with "<<>>" and change its background and foreground color.
Later on when the user clicks on a text that was formatted as described above the add-in kicks in and copies the text in clipboard
I am new to COM add-ins, and I wasn't able to find a good API documentation. I've started with VanillaAddIn (https://github.com/OneNoteDev/VanillaAddIn) and now I need to add my functionality. I would really appreciate any help with the following:
How to get the selected text from a page?
How to subscribe to the OnClick event?
Is there a good/decent OneNote API documentation? I found some links but I still hope there is a better one that I missed so far.
To get selected text from a page, look at the GetPageContent API. You can see it used here: https://github.com/OneNoteDev/VanillaAddIn/blob/master/VanillaConsole/Program.cs
From the page content xml, you can find some elements that are "selected".
OnClick event: There's no way to know when someone clicks on some text on the page, unfortunately.
One site that can help with parsing the page content is the OneNote XSD. Here: https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/63/17/0336.OneNoteApplication_2013_xsd.txt

Text selected / right click event (Outlook 2007 VBA)

I'm looking for an event that's raised when a user selects text in the preview pane of an email. E.g. you're viewing an email in the preview pane and select some text. I didn't see anything in the object reference to this effect, but the namespace is so large, it seems like there's always some object somewhere that does exactly what I need, which I'm not aware of.
Overall, what I'd like to do is see if the selected text matches a pattern and if so, insert a sub-menu in the right click menu (the one that says Copy, Who Is, Synonyms, Translate..). Help with this would be appreciated too. I believe the CommandBar is "text", but I'm unsure how to go about accessing this via name.
The Outlook object model doesn't provide anything for that.

Capture right-click'd text on Outlook Message Content

I'd like to know if it's possible to capture the text when a user right-click's on an Outlook message, and then add items to the right-click menu depending on the type of text.
This is an example of what I'd like to do. If there's a message (mail item) with the following content: "Hello, please call me at 555-8474 regarding item A1234" and the user right-click's on the number "8", the pop-up context menu will have an extra item at the bottom called "Call 555-8474", and a "PhoneCall" sub will be run if selected. If the user right-click's anywhere on "A1234" a different item (i.e. "Look up A1234") will be shown.
We're running Outlook 2003 and if possible I'd like to know if this can be done using VBA. I'm open to other ideas as well. Thanks!
You can use this example in VBA to get started
SmartTags is an Office 2003 feature that was designed for exactly this sort of thing. I honestly don't know SmartTags well enough to do more than wave in the general direction, so I hope you get a better answer from a domain expert....