Outlook 2002 Inspector isn't closing

  • Thread starter Thread starter Niels Hansen
  • Start date Start date
N

Niels Hansen

Hey all



I'v produced a com add-in based on the Inspector Wrapper and managed to do
all the operations I wanted via Office Developer (vba).

Basically it places a button next to the Send button in a mail item, to send
the mail with some special features, when mail is send, I want to close the
current item, as if the mail was send normally.



I tested the Com add-in on two different platforms.



Windows 2000, Outlook 2002 no errors.



Windows XP, Outlook 2002, Inspector will not close. The inspector window
stays open, but no menus are active. I can close the window in the upper
right corner.



Windows XP, Outlook 2003, same error.





I'm open for all suggestions.





Niels Hansen
 
Show the code you used. You aren't opening the Inspector modally are you?
 
Hey Ken
No, the Inspector is not opened modally.
The inspector is opend like you would write a new message, I simply place a
button next to Send, so they get som differens options

Here it comes:

--- Code start ---

Public Sub SendSecure(strFrom As String)
On Error Resume Next

Dim objCDOMsg As MAPI.Message
Dim objOl As Outlook.Application
Dim myinspector As Outlook.Inspector
Dim EmneFelt As String
Dim objFolder As Object
Dim objCDOSession As MAPI.Session
Dim objRecipient As Outlook.Recipient
Dim MsgID As String
Dim strStoreID As String

Set objCDOSession = CreateObject("MAPI.Session")
objCDOSession.Logon "", "", False, False, 0

Set objOl = CreateObject("Outlook.Application")
Set myinspector = objOl.ActiveInspector
Set myItem = myinspector.CurrentItem

myItem.Save
myItem.UserProperties.Add "Test", olNumber
Dim AddrList As String

Set objAddressList = objCDOSession.GetAddressList(CdoAddressListGAL)
AddrList = objAddressList

myItem.BCC = strFrom


myItem.Recipients.ResolveAll

myItem.Save

Set objAddressEntry = objAddressList.AddressEntries(strFrom)

MsgID = myItem.EntryID
strStoreID = myItem.Parent.StoreID

Set objCDOMsg = objCDOSession.GetMessage(MsgID, strStoreID)

If Not TypeName(myItem) = "Nothing" Then
EmneFelt = myItem.Subject
EmneFelt = "FORTROLIG - " & EmneFelt
objCDOMsg.Subject = EmneFelt
objCDOMsg.sender = objAddressEntry
objCDOMsg.Send
myItem_Send = False

myItem.Close (1)
Else

MsgBox "No open items"
End If

objCDOSession.Logoff
Set gOLApp = Nothing
Set objCDOMsg = Nothing
Set myItem = Nothing
Set myinspector = Nothing
Set objCDOSession = Nothing
Set objAddressList = Nothing
Set objAddressEntry = Nothing
End Sub

--- Code end ---

Regards

Niel
 
Me again,

The sub is declared withevents like all objects externally of the sub.
 
It looks OK, but I wonder if adding a recipient to the MAPI Message instead
of adding an AddressEntry to .Sender and then resolving the Recipient would
make a difference? Of course access to the Recipients collection will fire
the security prompts for secure versions of Outlook when using CDO 1.21
code.

The other thing I'm wondering is if using .Send on the myItem object (and
Dim'ing it and releasing it) rather than using .Send on the MAPI Message
object would make a difference? In any case I'd declare myItem and make sure
to release it.

I don't know if you've seen it but you also might want to take a look at the
InspectorWrapper code I've posted on my Web site at
http://www.slovaktech.com/code_samples.htm#InspectorWrapper and see if that
gives you any ideas.
 
Hi Ken

I solved the the problem.
The "sendsecure" sub is called from a user form. When I moved the
object.close (1) to the user form everything works fine.
I just don't understand why it works with Windows 2000 and not with Windows
XP.

Another problem I'm getting is the commandbutton.
If I open more inspectors and runs my code in one inspector, the
functionality of all other inspectors is released. No joy on clicking the
command button.
I think the inspector wrapper should provide me with a Unique ID for each
inspector. I just can't seem to get the correct ID from the wrapper when I
create the command button. I'm using the example from your posting on
Google. Just can't find the ID...

Any way, thanks for your input.

Niel
 
Each Inspector would have a Key property, which is a unique number that will
not be repeated during that Outlook session. I take that Key property and
add it to a string to get a unique Tag property for every command button.
That way when a button is clicked the Click event handler in only that
Inspector wrapper class fires.

In the Inspector wrapper class module is a variable named m_intID (Integer).
So in the button creation procedure which is located in the class module I
have code like this:
Dim strTag As String
strTag = "InspectorButton" & CStr(m_intID)

Since each class has a unique Key value and the text is unique to a button
in an Inspector, that guarantees a unique Tag. If I have more than 1 button
I change the text for each one, if I have Explorer buttons I start those
with "ExplorerButton" or something else that marks the buttons as different
than any Inspector buttons.
 
Back
Top