deploy 2003 vsto addin on outlook 2007 problem

  • Thread starter Thread starter lokesh
  • Start date Start date
L

lokesh

Hi,

Have created and deployed successfully, an outlook vsto addin for 2003. But
i am unable to install it on office 2007 for one of the machines as, it is
unable to install O2003PIA as it also requires office sp2. Whenever i try to
install offce sp2 it says product version not found. Is it because of the
registry problem since i do see the files and folders for 2003 on the system.
Is there something i am missing.
 
A VSTO addin compiled under Outlook 2003 will run unchanged on Outlook 2007.
It won't have support for the ribbon, forms regions or other new stuff but
it will just work.

Are you following the deployment walkthroughs for VSTO applications, using
that documentation I've never had a VSTO Outlook 2003 addin try to install
Outlook 2003 or the Outlook 2003 PIA's on an Outlook 2007 machine. You
wouldn't want that anyway, last registered wins in those cases so that would
make the Outlook 2007 PIA unavailable for that machine.

Is the Outlook 2007 PIA installed on that problem machine? If it is the code
should just install and run.
 
Thanks Ken for your reply. Have solved the problem. Yes O2003PIA was
installed. But had added it in launch condition, which would search for it
and could not fine. I have removed the launch condition, so its not
obstructing it now from installing.
 
Though, the addin got installed, its not behaving the way it should even
though i got it running with the same configuration in other machine.

The problem is a button which enables/disables other controls on the
toolbar, works for the first time the message (inspector) window is opened
after the outlook is opened. But then when i close the first window and open
another window, it stops disabling/enabling other controls. No exceptions are
occurring and cannot figure out what the problem could be.
 
That sounds like a scope issue. Are you declaring that object at a level
where it doesn't go out of scope and get garbage collected?

What type of button? Is this running on Outlook 2003 or 2007? For 2007 you
should be supporting the ribbon.

Also, if you intend to correctly handle things if more than one item is open
at a time you really should be wrapping your Inspectors in Inspector wrapper
classes and keeping them in a collection or list of some kind so you can
handle each separately.
 
Yes I am using Wrappers based on some of your samples. Have written it for
2003 but this problem is occurring for 2007 office on XP. Have tested it on
other xp machine with 2007 and it is working perfectly. Its on one particular
machine that its giving a problem.

-Lokesh
 
If it's only on one machine where you have the problem then you have to find
out what's different about that machine. Check for the addin pre-requisites,
requirements and anything else required in the environment of your problem
machine. Check your error logs and the Windows event logs. Try to run in
debug mode on that computer if possible.
 
Yes i guess I have found the solution for it. It was the anti-virus which was
causing the problem, for some security loophole in my code. I reproduced the
same problem on some other machine and fixed it. Will test it out some more.

But have some bringing the datepicker window to the top. Will post it in
other thread.
 
Hi Ken,

For writing a 2007 based addin, do we need to write similar wrappers and
handle the toolbars by using some data structure.

-Lokesh
 
For an Outlook 2007 based addin you should use the same structure of wrapper
classes and a collection or list to hold them. Your ribbon handler will be
in your Connection class but you still handle everything else the same way.
 
Have migrated the code to 2007 addin. The addin works fine except for the
first time. When the inspector window opens for the first time the addin
loads, but does not behave properly. The button which enables/disables the
remaining controls, receives two button-click events. But it works as fine
after that. What could be the cause? So, buffer/stack overflows or something?
 
No idea without seeing the relevant code you are using.

Usually if a button receives two click events for each click you have
duplicate buttons, possibly from a previous instance. Or you have set up the
Parameters to call something that forces the second click, but that would
apply to all times the button was clicked.

Have you stepped your code to see what's happening?
 
Hi Ken,

Have tried stepping but to no avail. Anyways here is my code:

Inspector wrapper (based on your template):

internal class InspectorWrapper : WrapperClass
{
Outlook.Application outlookApp = new Outlook.Application();

public Outlook.Inspector inspector;
Office.CommandBar _CommandBar = null;
Office.CommandBarButton _TrackButton;
Office.CommandBarComboBox _BAComboBox = null;
Office.CommandBarComboBox _DueDateText;
Office.CommandBarButton _DueDateBtn;
WindowHandle owner;


Office.CommandBarButton _TBitsBtn;
Office.CommandBarButton _SmsBtn;

Office.CommandBarComboBox _CategoryComboBox;
Office.CommandBarComboBox _StatusComboBox;

DatePicker dp;

//Word.Document wordDoc;
Outlook.MailItem curMailItem = null;
BAXmlParser baXmlParser = BAXmlParser.GetInstance();
BA curBA = null;
static string prevBA="";
string category, status;
Regex fwPattern= new Regex("FW: +[a-zA-Z]+#[0-9]+:.*");

string toolbarName = "tBits Plugin";
bool newCompose = false;
bool firstActivate = true;
const int startIndex = 1;

protected object _Missing = System.Reflection.Missing.Value;

string newLine = "\n";

public IntPtr hWnd;

public InspectorWrapper(Outlook.Inspector inspector)
{
try
{
this.inspector = inspector;
if (inspector.CurrentItem is Outlook.MailItem)
curMailItem = (Outlook.MailItem)inspector.CurrentItem;
else
return;
ConnectEvents();
currentId = Id.ToString();
owner = new WindowHandle(inspector);
hWnd = owner.Handle;

if (!inspector.IsWordMail())
{
//wordDoc = ((Word.Document)(inspector.WordEditor));
//owner = new WindowHandle(wordDoc.ActiveWindow);
CreateToolBar();
}
}
catch (System.Exception ex)
{
}
}

void ConnectEvents()
{
((Outlook.InspectorEvents_10_Event)inspector).Activate +=
new
Outlook.InspectorEvents_10_ActivateEventHandler(InspectorWrapper_Activate);

((Outlook.InspectorEvents_10_Event)inspector).Close +=
new
Outlook.InspectorEvents_10_CloseEventHandler(InspectorWrapper_Close);
((Outlook.InspectorEvents_10_Event)inspector).Deactivate +=
new
Outlook.InspectorEvents_10_DeactivateEventHandler(InspectorWrapper_Deactivate);
((Outlook.ItemEvents_10_Event)curMailItem).Send +=
new
Microsoft.Office.Interop.Outlook.ItemEvents_10_SendEventHandler(InspectorWrapper_Send);
((Outlook.ItemEvents_10_Event)curMailItem).Reply +=
new
Microsoft.Office.Interop.Outlook.ItemEvents_10_ReplyEventHandler(InspectorWrapper_Reply);
((Outlook.ItemEvents_10_Event)curMailItem).Forward +=
new
Outlook.ItemEvents_10_ForwardEventHandler(InspectorWrapper_Forward);
}

void DisconnectEvents()
{
((Outlook.InspectorEvents_10_Event)inspector).Activate -=
new
Outlook.InspectorEvents_10_ActivateEventHandler(InspectorWrapper_Activate);

((Outlook.InspectorEvents_10_Event)inspector).Close -=
new
Outlook.InspectorEvents_10_CloseEventHandler(InspectorWrapper_Close);
((Outlook.InspectorEvents_10_Event)inspector).Deactivate -=
new
Outlook.InspectorEvents_10_DeactivateEventHandler(InspectorWrapper_Deactivate);
((Outlook.ItemEvents_10_Event)curMailItem).Send -=
new
Microsoft.Office.Interop.Outlook.ItemEvents_10_SendEventHandler(InspectorWrapper_Send);
((Outlook.ItemEvents_10_Event)curMailItem).Reply -=
new
Microsoft.Office.Interop.Outlook.ItemEvents_10_ReplyEventHandler(InspectorWrapper_Reply);
((Outlook.ItemEvents_10_Event)curMailItem).Forward -=
new
Outlook.ItemEvents_10_ForwardEventHandler(InspectorWrapper_Forward);
}

void InspectorWrapper_Close()
{
DisconnectEvents();
inspector = null;
GC.Collect();
GC.WaitForPendingFinalizers();
OnClosed();
}

#region Activate / Deactivate
void InspectorWrapper_Activate()
{
if (inspector.IsWordMail() && (firstActivate))
{
CreateToolBar();
firstActivate = false;
}
currentId = Id.ToString();
}

void InspectorWrapper_Deactivate()
{
previousId = Id.ToString();
}

void InspectorWrapper_Send(ref bool cancel)
{
string assigneeStr = null;
string trackStr = null;
string subscriberStr = null;

if (_TrackButton.State == Office.MsoButtonState.msoButtonDown)
{
try
{
assigneeStr = curMailItem.To;
curMailItem.RecipientReassignmentProhibited = false;
curMailItem.To = curBA.email;
if (curMailItem.CC != null)
{
subscriberStr = curMailItem.CC;
curMailItem.CC = "";
}

curMailItem.Recipients.ResolveAll();

if (isBA(assigneeStr))
assigneeStr = "";
else
{
trackStr = "/assignee:" + assigneeStr + newLine;
}

if (subscriberStr != null)
trackStr = trackStr+"/subscribers:" + subscriberStr
+ newLine;

if (_DueDateText.Text == "")
if (newCompose)
trackStr = trackStr + "/dueby:" +
DateTime.Today.AddDays(2).ToShortDateString()
+ newLine;
else
trackStr = trackStr + newLine;
else
trackStr = trackStr + "/dueby:" + _DueDateText.Text
+ newLine;

//if ((_CategoryBtn.State ==
Office.MsoButtonState.msoButtonDown) &&
if (category != null)
trackStr = trackStr + "/category_id:" + category +
newLine;

//if ((_StatusBtn.State ==
Office.MsoButtonState.msoButtonDown) &&
if (status != null)
trackStr = trackStr + "/status:" + status + newLine;

if (_SmsBtn.State == Office.MsoButtonState.msoButtonDown)
trackStr = trackStr + "/SendSMS:" + true + newLine;


curMailItem.Body = trackStr + newLine +
curMailItem.Body.Replace("\\n", Environment.NewLine);
}
catch (Exception exp)
{
MessageBox.Show(owner,exp.StackTrace + "\n" + "Message:"
+ exp.Message);
}
}
}

void InspectorWrapper_Reply(Object obj, ref bool cancel)
{
newCompose = false;
}

void InspectorWrapper_Forward(Object obj, ref bool cancel)
{
newCompose = true;
}

#endregion

private void CreateToolBar()
{
int index = 1;
try
{
//baXmlParser.reloadXml();
if (inspector == null) return;

if (inspector.IsWordMail())
{
// check, if there is already our CommandBar
foreach (Office.CommandBar bar in inspector.CommandBars)
{
if (((bar.Name).Contains("tBits Plugin")) &&
inspector.IsWordMail())
{
bar.Visible = false;
bar.Enabled = false;
}
}
_CommandBar = inspector.CommandBars.Add("tBits Plugin" +
Id.ToString(), _Missing, _Missing, true);
}
else
{
foreach (Office.CommandBar bar in inspector.CommandBars)
{
if (bar.Name == toolbarName)
{
_CommandBar = bar;
foreach (Office.CommandBarControl ctrl in
_CommandBar.Controls)
{
ctrl.Delete(false);
}
break;
}
}

// If we found our CommandBar, we can use it
if (_CommandBar == null)
{
// if not we create one
try
{
_CommandBar =
inspector.CommandBars.Add(toolbarName,
_Missing, _Missing, true);
}
catch (Exception exp)
{
MessageBox.Show(owner,"Exception positioning
inspector commandbar: " + exp.StackTrace
+"\n\nMessage: "+exp.Message);
}
}
}

// Set newCompose value based on whether the opened window
is New message/reply/forward window
setNewCompose(curMailItem);

// Add _ button
_TrackButton =
(Office.CommandBarButton)_CommandBar.Controls.Add(
Office.MsoControlType.msoControlButton, 1, _Missing,
index++, 1);

_TrackButton.Caption = "Track";
_TrackButton.Tag = Id.ToString();
_TrackButton.Style = Office.MsoButtonStyle.msoButtonCaption;

// Register for Click event
_TrackButton.Click += new
Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(
_Track_Btn_Click);

// Add _ ComboBox Control
_BAComboBox =
(Office.CommandBarComboBox)_CommandBar.Controls.Add(
Office.MsoControlType.msoControlComboBox, 1, _Missing,
index++, 1);
_BAComboBox.Caption = "BA:";
_BAComboBox.Width = 150;
_BAComboBox.Style = Office.MsoComboStyle.msoComboLabel;
_BAComboBox.Tag = Id.ToString();
// Fill the ComboBox
fillBAComboBox();
_BAComboBox.Change += new
Microsoft.Office.Core._CommandBarComboBoxEvents_ChangeEventHandler(
_BA_ComboBox_Change);

//Button to set due date
_DueDateText =
(Office.CommandBarComboBox)_CommandBar.Controls.Add(
Office.MsoControlType.msoControlEdit, 1, _Missing,
index++, 1);
_DueDateText.BeginGroup = true;
_DueDateText.Width = 115;
_DueDateText.Caption = "Due date:";
_DueDateText.Style = Office.MsoComboStyle.msoComboLabel;
string curSubject = null;
if (curMailItem.Subject == null)
curSubject = "";
else
curSubject = curMailItem.Subject;
if ((newCompose) && (!fwPattern.IsMatch(curSubject)))
_DueDateText.Text =
DateTime.Today.AddDays(2).ToShortDateString();
else
_DueDateText.Text = null;
_DueDateText.Visible = true;
_DueDateText.Tag = Id.ToString();
_DueDateText.Change += new
Office._CommandBarComboBoxEvents_ChangeEventHandler(
_Due_Date_Change_Event);

_DueDateBtn =
(Office.CommandBarButton)_CommandBar.Controls.Add(
Office.MsoControlType.msoControlButton, 1, _Missing,
index++, 1);
_DueDateBtn.Width = 10;
_DueDateBtn.Style = Office.MsoButtonStyle.msoButtonIcon;
_DueDateBtn.FaceId = 125;
_DueDateBtn.Tag = Id.ToString()+"_DueDateBtn";
_DueDateBtn.Click += new
Office._CommandBarButtonEvents_ClickEventHandler(
_Due_Date_Btn_Click);

dp = new DatePicker();
dp.Tag = Id.ToString() + "_DatePicker";
dp.ResumeLayout(true);
dp.dateTimePicker1.Value = System.DateTime.Now;
dp.dateTimePicker1.CreateControl();
dp.Enabled = false;
dp.Deactivate += new EventHandler(dp_Deactivate);
dp.Activated += new EventHandler(dp_Activated);
dp.dateTimePicker1.MouseLeave += new
EventHandler(dateTimePicker1_Leave);
dp.dateTimePicker1.TextChanged += new
EventHandler(_DP_Date_Change_Event);

_CategoryComboBox =
(Office.CommandBarComboBox)_CommandBar.Controls.Add(
Office.MsoControlType.msoControlComboBox, 1, _Missing,
index++, 1);
_CategoryComboBox.Caption = "Category";
_CategoryComboBox.Style = Office.MsoComboStyle.msoComboLabel;
_CategoryComboBox.Width = 150;
_CategoryComboBox.Enabled = true;
fillCategoryComboBox();
_CategoryComboBox.Tag = Id.ToString().ToString() +
"_CategoryComboBox";
_CategoryComboBox.Change += new
Office._CommandBarComboBoxEvents_ChangeEventHandler(
_Category_Change_Event);

_StatusComboBox =
(Office.CommandBarComboBox)_CommandBar.Controls.Add(
Office.MsoControlType.msoControlComboBox, 1, _Missing,
index++, 1);
_StatusComboBox.Caption = "Status";
_StatusComboBox.Style = Office.MsoComboStyle.msoComboLabel;
_StatusComboBox.Width = 150;
_StatusComboBox.Enabled = true;
fillStatusComboBox();
_StatusComboBox.Tag = Id.ToString().ToString() +
"_StatusComboBox";
_StatusComboBox.Change += new
Office._CommandBarComboBoxEvents_ChangeEventHandler(
_Status_Change_Event);

_SmsBtn = (Office.CommandBarButton)_CommandBar.Controls.Add(
Office.MsoControlType.msoControlButton, 1, _Missing,
index++, 1);
_SmsBtn.Width = 30;
_SmsBtn.Caption = "SMS";
_SmsBtn.BeginGroup = true;
_SmsBtn.Style = Office.MsoButtonStyle.msoButtonCaption;
_SmsBtn.Tag = Id.ToString().ToString() + "_SmsBtn";
_SmsBtn.Click += new
Office._CommandBarButtonEvents_ClickEventHandler(
_Sms_Btn_Click);
_SmsBtn.Visible = true;

_TBitsBtn = (Office.CommandBarButton)_CommandBar.Controls.Add(
Office.MsoControlType.msoControlButton, 1, _Missing,
index, 1);
_TBitsBtn.Visible = true;
_TBitsBtn.Caption = "tBits";
_TBitsBtn.TooltipText = "Link to tBits login page";
_TBitsBtn.Tag = Id.ToString().ToString() + "tBitsBtn";
_TBitsBtn.Style =
Office.MsoButtonStyle.msoButtonIconAndCaption;
_TBitsBtn.Click += new
Office._CommandBarButtonEvents_ClickEventHandler(
_TBits_Btn_Click);
try
{
Clipboard.Clear();
// Read the bitmap from resources
System.Drawing.Bitmap bmp = Properties.Resources.logo;
// Copy image to clipboard
Clipboard.SetImage(bmp);
_TBitsBtn.PasteFace();
}
catch (Exception exp)
{
MessageBox.Show(owner,"Image loading:" + exp.StackTrace);
}

// Make Menu Visible in TOP of Menus
_CommandBar.Visible = true;
_CommandBar.Enabled = true;
_CommandBar.Position = Office.MsoBarPosition.msoBarTop;

disableTrackButtons();
setTrackForReplyForward();
}
catch (System.Exception ex)
{
MessageBox.Show(owner,"StackTrace: \n
"+ex.StackTrace+"\n\nMessage: \n"+ex.Message);
}
}

#region Toolbar events

void _Track_Btn_Click(Office.CommandBarButton Ctrl, ref bool
cancelDefault)
{
if (Ctrl.Tag != currentId.ToString())
{
//MessageBox.Show("Id's did not match");
return;
}

switch (Ctrl.State)
{
case (Office.MsoButtonState.msoButtonUp):
{
Ctrl.State = Office.MsoButtonState.msoButtonDown;

//MessageBox.Show(owner,"Track is enabled");
enableTrackButtons();
break;
}
case (Office.MsoButtonState.msoButtonDown):
{
Ctrl.State = Office.MsoButtonState.msoButtonUp;
disableTrackButtons();
//MessageBox.Show(owner,"Track is disabled");

break;
}
}
}

void _BA_ComboBox_Change(Office.CommandBarComboBox Ctrl)
{
try
{
//For inspector window
foreach (BA bizArea in baXmlParser.getBusinessAreas())
{
try
{
if (bizArea.displayName == _BAComboBox.Text)
{
curBA = bizArea;
prevBA = bizArea.displayName;
break;
}
}
catch (Exception)
{
return;
}
}
_CategoryComboBox.Clear();
fillCategoryComboBox();
_StatusComboBox.Clear();
fillStatusComboBox();
}
catch (Exception exp)
{
MessageBox.Show(owner,"Exception while changing BA:\n" +
exp.StackTrace +
"\nMessage:\n" + exp.Message);
}
}

void _Category_Change_Event(Office.CommandBarComboBox categoryCtrl)
{
if (categoryCtrl.Tag != Id.ToString() + "_CategoryComboBox")
return;
category = categoryCtrl.Text;
}

void _Status_Change_Event(Office.CommandBarComboBox statusCtrl)
{
if (statusCtrl.Tag != Id.ToString() + "_StatusComboBox") return;
status = statusCtrl.Text;
}

void _Due_Date_Btn_Click(Office.CommandBarButton ctrl, ref bool
cancelDefault)
{
if ((ctrl.Tag == Id.ToString() + "_DueDateBtn")) //&&
((String)dp.Tag == Id.ToString() + "_DatePicker"))
try
{
dp.Enabled = true;
dp.Size = new System.Drawing.Size(110, 40);
dp.Location = new System.Drawing.Point(ctrl.Left,
ctrl.Top + ctrl.Height);
dp.TopMost= true;
dp.ShowDialog(owner);
dp.Activate();
if ((dp.Enabled) && (!dp.Focused))
{
dp.TopMost = true;
dp.Focus();
}

_DueDateText.Visible = true;

}
catch (Exception exp)
{
MessageBox.Show(owner,"Exception while creating date
picker:\n" + exp.StackTrace
+ "Message:\n" + exp.Message);
}
}

void _DP_Date_Change_Event(Object ctrl, EventArgs evArgs)
{
if ((String)dp.Tag == Id.ToString() + "_DatePicker")
{
_DueDateText.Text = dp.dateTimePicker1.Text;
_DueDateText.Visible = true;
dp.Close();
}
}

void dp_Deactivate(Object ctrl, EventArgs evArgs)
{
if ((String)dp.Tag == Id.ToString() + "_DatePicker")
{
dp.Close();
}
}

void dp_Activated(Object ctrl, EventArgs evArgs)
{
if ((String)dp.Tag == Id.ToString() + "_DatePicker")
{
//MessageBox.Show("AcT");
dp.TopMost= true;
}
}

void dateTimePicker1_Leave(Object ctrl, EventArgs evArgs)
{
dp.Close();
}

void _Sms_Btn_Click(Office.CommandBarButton smsCtrl, ref
bool cancelDefault)
{
if (smsCtrl.Tag == Id.ToString() + "_SmsBtn")
if (smsCtrl.State == Office.MsoButtonState.msoButtonUp)
{
smsCtrl.State = Office.MsoButtonState.msoButtonDown;
}
else
{
smsCtrl.State = Office.MsoButtonState.msoButtonUp;
}
}

void _TBits_Btn_Click(Office.CommandBarButton tBitsCtrl, ref bool
cancelDefault)
{
try
{
tBitsCtrl.TooltipText =
Properties.Settings.Default.tBitsWebLink;
tBitsCtrl.HyperlinkType =
Office.MsoCommandBarButtonHyperlinkType.msoCommandBarButtonHyperlinkOpen;
}
catch (Exception exp)
{
MessageBox.Show(owner,exp.StackTrace + "\n Message: " +
exp.Message);
}
}

void enableTrackButtons()
{
_BAComboBox.Enabled = true;
_DueDateText.Enabled = true;
_DueDateBtn.Enabled = true;
_SmsBtn.Enabled = true;
_CategoryComboBox.Enabled = true;
_StatusComboBox.Enabled = true;
}

void disableTrackButtons()
{
_BAComboBox.Enabled = false;
_DueDateText.Enabled = false;
_DueDateBtn.Enabled = false;
_SmsBtn.Enabled = false;
_CategoryComboBox.Enabled = false;
_StatusComboBox.Enabled = false;
}

void fillBAComboBox()
{
bool defValueSet = false;
int count = startIndex;
foreach (BA bizArea in baXmlParser.getBusinessAreas())
{
try
{
if (bizArea != null)
{
_BAComboBox.AddItem(bizArea.displayName, count++);
if (!defValueSet)
if (prevBA == "")
{
_BAComboBox.Text = bizArea.displayName;
curBA = bizArea;
defValueSet = true;
prevBA = _BAComboBox.Text;
}
else
if (bizArea.displayName == prevBA)
{
_BAComboBox.Text = prevBA;
curBA = bizArea;
defValueSet = true;
}
}
}
catch (Exception exp)
{
MessageBox.Show(owner,exp.StackTrace + "Message:" +
exp.Message);
}
}
}

void fillCategoryComboBox()
{
try
{
foreach (BA bizArea in baXmlParser.getBusinessAreas())
{
if (bizArea.displayName == _BAComboBox.Text)
{
foreach (string str in bizArea.baCategory)
_CategoryComboBox.AddItem(str, startIndex);
break;
}
}
}
catch (Exception exp)
{
MessageBox.Show(owner,"Exception occured while filling
category combobox\n" + exp.StackTrace
+ "\n\n Message:\n" + exp.Message);
}
}

void fillStatusComboBox()
{
try
{
foreach (BA bizArea in baXmlParser.getBusinessAreas())
{
if (bizArea.displayName == _BAComboBox.Text)
{
foreach (string str in bizArea.baStatus)
_StatusComboBox.AddItem(str, startIndex);
break;
}
}
}
catch (Exception exp)
{
MessageBox.Show(owner,"Exception occured while filling
category combobox\n" + exp.StackTrace
+ "\n\n Message:\n" + exp.Message);
}
}

#endregion

#region auxiliary functions

void setNewCompose(Outlook.MailItem item)
{
if (item.To == null)
newCompose = true;
else
newCompose = false;
}

private void setTrackForReplyForward()
{
try
{
BA matchedBA = null;
//Outlook.MailItem mItem =
(Outlook.MailItem)((Outlook.Inspector)activeObj).CurrentItem;
//Check if the mail is being replied
matchedBA = getBAFromEmail(curMailItem.To);

//Check if the mail is being forwarded fwPattern
if ((curMailItem.Subject != null) &&
((curMailItem.Subject).StartsWith("FW")))
if (fwPattern.IsMatch(curMailItem.Subject))
{
matchedBA = getBaFromPrefix(curMailItem.Subject);
}
//if anyone of the above is true, set track controls
if (matchedBA != null)
setTrackOptions(matchedBA);
}
catch (Exception exp)
{
MessageBox.Show(owner,"Exception while checking for existing
BA" + exp.StackTrace
+ "\n Message: " + exp.Message);
}
}

private void setTrackOptions(BA matchedBA)
{
//Set the values for track controls based on the business area
_TrackButton.State = Office.MsoButtonState.msoButtonDown;
enableTrackButtons();
_BAComboBox.Text = matchedBA.displayName;
curBA = matchedBA;
}

ThisAddin code

// Inspectors stuff
_Inspectors = this.Inspectors;
_Inspectors.NewInspector += new
Outlook.InspectorsEvents_NewInspectorEventHandler(_Inspectors_NewInspector);

// Are there any open Inspector after Startup ?
for (int i = _Inspectors.Count; i >= 1; i--)
{
// Wrap the Inspector and do something useful with it
WrapInspector(_Inspectors);
}

-Lokesh
 
Back
Top