Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7738233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:12:43+00:00 2026-06-01T08:12:43+00:00

Mine is a bit of odd solution. I want to scan for a particular

  • 0

Mine is a bit of odd solution.
I want to scan for a particular string of words (these particular string of words are already in an XML data file) to achieve this i have thought of going this thru these following steps
I will have a menubaritem to change settings of the add-in(not necessary now)
I will have a button like the new button in the bar like this

http://www.packtpub.com/sites/default/files/Article-Images/vsto-article1-image5.png

http://www.packtpub.com/article/microsoft-office-outlook-programming-vsto-c-sharp-part1

then say the user is reading an item that is selected and opened in the reading pane. when my button is pressed i want the code to scan the subject and the body to match with my xml data, if it exists then show a message box.

I did as far as creating a menuitem and menubar button and the xml data, now my question is how to scan the currently being read item?

This is my C# code in thisaddin.cs

  using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
using System.Windows.Forms;

namespace Sql_openertake1
{
    public partial class ThisAddIn
    {
        private Office.CommandBar menuBar;
        private Office.CommandBarPopup newMenuBar;
        private Office.CommandBarButton buttonOne;
        Office.CommandBarButton PacktButtonA;
        Office.CommandBar PacktCustomToolBar;

        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {

         // Verify the PacktCustomToolBar exist and add to the application
if (PacktCustomToolBar == null)
{
// Adding the commandbar to Active explorer
Office.CommandBars PacktBars = this.Application.
ActiveExplorer().CommandBars;
// Adding PacktCustomToolBar to the commandbars
PacktCustomToolBar = PacktBars.Add("SQL Opener",Office.MsoBarPosition.msoBarTop, false, true);
}
// Adding button to the custom tool bar
Office.CommandBarButton MyButton1 = (Office.
CommandBarButton)PacktCustomToolBar.Controls.Add(1,
missing, missing, missing, missing);
// Set the button style
MyButton1.Style = Office.MsoButtonStyle.msoButtonCaption;
// Set the caption and tag string
MyButton1.Caption = "Open";
MyButton1.Tag = "MY BUTTON";
if (this.PacktButtonA == null)
{
// Adding the event handler for the button in the toolbar
this.PacktButtonA = MyButton1;
PacktButtonA.Click += new Office.
_CommandBarButtonEvents_ClickEventHandler(ButtonClick);
}
}
// Button event in the custom toolbar
private void ButtonClick(Office.CommandBarButton ButtonContrl,
ref bool CancelOption)
{
// Message box displayed on button click
MessageBox.Show(ButtonContrl.Caption + " Says Hello World!");
}

        private void AddMenuBar()
        {
            try
            {
                menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar;
                newMenuBar = (Office.CommandBarPopup)menuBar.Controls.Add(
                    Office.MsoControlType.msoControlPopup, missing,
                    missing, missing, true);
                if (newMenuBar != null)
                {
                    newMenuBar.Caption = "SQL Opener";
                    buttonOne = (Office.CommandBarButton)newMenuBar.Controls.
                    Add(Office.MsoControlType.msoControlButton, missing,
                        missing, 1, true);
                    buttonOne.Style = Office.MsoButtonStyle.
                        msoButtonIconAndCaption;
                    buttonOne.Caption = "Settings";
                    buttonOne.FaceId = 0548;
                    buttonOne.Tag = "c123";
                    buttonOne.Click += new Office._CommandBarButtonEvents_ClickEventHandler(buttonOne_Click);
                    newMenuBar.Visible = true;
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }

        private void buttonOne_Click(Office.CommandBarButton ctrl,
            ref bool cancel)
        {
            System.Windows.Forms.MessageBox.Show("You clicked: " + ctrl.Caption,
                "Custom Menu", System.Windows.Forms.MessageBoxButtons.OK);

        }


        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
        }

        private void createnewform()
        {
            SAmple_form sform = new SAmple_form();
            sform.Text = "Show the Count";


        }

        #region VSTO generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InternalStartup()
        {
            this.Startup += new System.EventHandler(ThisAddIn_Startup);
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
        }

        #endregion
    }
}

this is my xml data

<?xml version="1.0" encoding="utf-8" ?>
<words>
    <word id="5001">None</word>
    <word id="5002">Glazed</word>
    <word id="5005">Sugar</word>
    <word id="5006">Sprinkles</word>
    <word id="5003">Chocolate</word>
    <word id="5004">Maple</word>

</words>

thanks for the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:12:44+00:00Added an answer on June 1, 2026 at 8:12 am

    http://msdn.microsoft.com/en-us/library/ms268994%28v=vs.100%29.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a bit of an odd question. A friend of mine and I
I fund few posts to explode data as array but mine is bit specific
OK this is a very common problem but mine is a bit different and
There are a lot of similar questions, but, probably, mine is a little bit
A colleague of mine has written a DLL file for me to use called
This may seem a bit odd, but I really need to create a workaround
I've seen a few questions like this, but mine is a bit more specific
While there are already quite a few posts about leaks around UIWebView, mine is
I have a bit of a problem with some squares of mine. They are
Being a bit lazy, I'd like to add some properties of mine to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.