Strange Subject Line Behavior

G

gwolinsky

I have run across a strange problem. I have created a simple Outlook
2003 Add-in using VSTO in VS2005.

When a new mail message inspector is opened, I add a button to the
inspector's command bar. This button simply appends some standard text
on the end of whatever subject line text is already there if it has not
already been done. I check to see if the standardized text is on the
end of subject. If it's not, I add it.

It's really rather simple and works great (even with multiple
inspectors open) except for one strange issue.

When I enter some text in the subject line, if I DON'T exit the subject
textbox, whatever text I've entered doesn't show up in the mail message
object. So, when I go to add the standard text, whatever text I've
already keyed isn't there and my code erases it when it resets the
subject textbox.

If I key in some text and EXIT the subject textbox, then, when I click
the button, the mail object sees the text just fine and appends the
standard text to it as it should.

Has anyone else seen this behavior? It seems that the text in the
subject line textbox is not available to the mail message object until
you exit the field.

Any help or information would be greatly appreciated.

Sincerely,
Glen Wolinsky

Code Below
---------------------------
Public Class ThisApplication

Const PRIV_TEXT As String = " - Confidential Attorney Work Product
- Subject to Privilege"
Private WithEvents confidentialButton As Office.CommandBarButton
Private WithEvents olInspectors As Outlook.Inspectors =
Me.Inspectors


Private Sub ThisApplication_Startup(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.Startup


End Sub

Private Sub ThisApplication_Shutdown(ByVal sender As Object, ByVal
e As System.EventArgs) Handles Me.Shutdown

End Sub

Private Sub NewInspector(ByVal insp As Outlook.Inspector) Handles
olInspectors.NewInspector

If TypeOf (insp.CurrentItem) Is Outlook.MailItem Then
Dim bar As Office.CommandBar = insp.CommandBars("Standard")

confidentialButton =
bar.Controls.Add(Office.MsoControlType.msoControlButton,
Temporary:=True)
With confidentialButton
.Caption = "Privilaged Tag"
.Style = MsoButtonStyle.msoButtonCaption
AddHandler .Click, AddressOf confidentialButton_Click
End With

End If

End Sub


Private Sub confidentialButton_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)

Dim draft As Outlook.MailItem =
DirectCast(ActiveInspector.CurrentItem, Outlook.MailItem)

If Not draft.Subject.EndsWith(PRIV_TEXT) Then
draft.Subject = Trim(draft.Subject) & PRIV_TEXT
End If


End Sub


End Class
 
G

gwolinsky

Is there any way to force that posting in code so as to accept whatever
text has been keyed?

Thanks,
Glen
 
K

Ken Slovak - [MVP - Outlook]

Not that I know of but I've never tried. I'm sure you could do it with
plenty of Win32 API calls and hooking all messages to that rich text
control, a window under the primary email window.
 
G

gwolinsky

Thanks for the info. If I might trouble you further.

This add-in has created a problem. We have a document management
system (MailSite from iManage) that integrates with Outlook 2003. You
can view and manipulate documents in the system from the OL2k3
interface. When you open a doc to view it, it checks it out. If you
haven't edited it, then when you exit OL it checks it back in.

When I load my add-in, that check-in never takes place. I'm assuming
that the problem is related to the known issue for which AddInMon was
created. The AddInMon information mentions using it for OL2k and OL2k2
but do I need this solution for OL2k3?

Thanks,
Glen
 
K

Ken Slovak - [MVP - Outlook]

Outlook 2003 has the same problems. Outlook 2007 seems to finally have fixed
that bug.
 
G

gwolinsky

I have been trying to work through using AddInMon, but have not been
able to get it to work yet. The code included in the examples look
like VB6. Has anyone done this in VB.NET using VS2k5? I'm a beginner
with Outlook programming and seem to be in a bit over my head.

Should I be looking at modifying the main email form instead?

Thanks,
Glen
 
K

Ken Slovak - [MVP - Outlook]

AddInMon was written in VB 6. To my knowledge there have been no
translations into any other language, and we're not planning to update it
further. We've come up with an inline alternative to AddInMon (VB 6 only at
this point) that does better than AddInMon in handling all the variations
that come with different Outlook versions and ways Outlook starts with no
UI.

The inline replacement has not been released yet. I'm adapting it to VB.NET
and C# and plan to release the templates in conjunction with my Outlook 2007
programming book (although parenthetically Outlook 2007 solves the
OnDisconnection won't fire problem).

My opinion is that I avoid the use of custom forms unless they are
absolutely necessary. Custom forms are a less than robust solution and are
prone to forms cache corruption and various other problems. In all cases,
unless my client drags me there kicking and screaming, I do everything in
COM addins and avoid forms like the plague. Your mileage might vary.
 
G

gwolinsky

Ken,

Your response begs the question: When do you plan on your Outlook 2007
book coming out? Or, is it possible to get your inline adaptation any
sooner?

We will not be going to OL2k7 for quite some time and some of our
attorneys REALLY want this feature.

Thanks,
Glen
 
K

Ken Slovak - [MVP - Outlook]

My book will probably be released around the end of the year, about when
Outlook 2007 is released.

As I said, I don't plan to release the inline templates for VB/VB.NET/C#
until the book comes out.

AddInMon still works in most scenarios and can be used as is and downloaded
from the Microeye Web site. The calls to AddInMon use VB 6 code but there's
nothing to stop you from translating those calls into VB.Net or other
language of your choice. The source for that is only a few lines and the
source is available.

AddInMon is only available as an EXE and the source is filled with Win32 API
calls that wouldn't really translate into .NET code anyway.
 
G

gwolinsky

Does anyone out there have an example of implementation of AddInMon in
VSTO 2005 with Outlook 2003? I just haven't been able to figure this
out.

Thanks,
Glen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top