How to resolve File Send Page by E-mail

Add-in Express™ Support Service
That's what is more important than anything else

How to resolve File Send Page by E-mail
 
mdriver


Guest


Hi

Welcome back from holiday I hope you enjoyed them.

I have an issue that I have been trying to resolve myself for a few months but have hit a brick wall on how to handle the problem. If you perform any of the following tasks:

Search for file in windows: Select Send To Mail Recepient
In Internet Explorer: Select Send Page via e-mail
In internet Explorer: Select button from toolbar Mail New Message
In internet Explorer: Select button from toolbar Mail Send Page
In Word: Select Sent To Mail Recepient (As Attachment)

Note: Outlook is Open when this function is performed
Word is not my e-mail editor

Now the majority of the time this does not cause an issue with my Outlook Add-in but some time probably about every 5th attempt the add-in causes an exception in the explorer Selection Change event. The exception that is generated is the AddinModule_OnError. I am trying to find the exact line that causes the issue but I believe whenever I query the explorer object or object_ = selection.Item(1) it occurs.

I have been unable to determine a way to handle this exception and wonder if you have any ideas I can try. Basically if an e-mail is created from any of the above I just want to exit my code and do nothing.

I use Outook spy and when I create any e-mail using the above methods its toolbar disappears so their must be a way of determining that the e-mail has been created outside of outlook and handling it I just do not know how.


thx

Matt


My current Explorer Activate code:

 Private Sub AddinModule_OlExplorerSelectionChange(ByVal sender As Object, ByVal explorer As Object) Handles MyBase.OlExplorerSelectionChange

        Try

            WriteDebugLine("Starting Function: AddinModule_OlExplorerSelectionChange")

            If ByPass_Explorer_Event = True Then
                WriteDebugLine("Starting Event: AddinModule_OlExplorerSelectionChange ByPass Event")
            Else
                Cursor.Current = Cursors.WaitCursor

                If TypeName(explorer) <> "nothing" Then
                    WriteDebugLine("TypeName(explorer) <> nothing")
                    If (explorer.Class <> 34) Then
                        SetToolbarForNoData("This is not an e-mail, Please only select a single e-mail")
                        Cursor.Current = Cursors.Default
                        Exit Sub
                    End If

                    If explorer.CurrentFolder.Name = "Outbox" Then
                        WriteDebugLine(explorer.CurrentFolder.Name = "Outbox")
                        SetToolbarForNoData("Toolbar cannot be used in your Outbox folder.")
                        Cursor.Current = Cursors.Default
                        Exit Sub
                    End If

                    If explorer.CurrentFolder.Name = "Calendar" Then
                        WriteDebugLine(explorer.CurrentFolder.Name = "Calender")
                        SetToolbarForNoData("Toolbar cannot be used in your Calender folder.")
                        Cursor.Current = Cursors.Default
                        Exit Sub
                    End If

                    If explorer.CurrentFolder.Name = "Tasks" Then
                        WriteDebugLine(explorer.CurrentFolder.Name = "Tasks")
                        SetToolbarForNoData("Toolbar cannot be used in your Tasks folder.")
                        Cursor.Current = Cursors.Default
                        Exit Sub
                    End If

                    If explorer.CurrentFolder.Name = "Notes" Then
                        WriteDebugLine(explorer.CurrentFolder.Name = "Notes")
                        SetToolbarForNoData("Toolbar cannot be used in your Notes folder.")
                        Cursor.Current = Cursors.Default
                        Exit Sub
                    End If

                    If explorer.CurrentFolder.Name = "Contacts" Then
                        WriteDebugLine("explorer.CurrentFolder.Name  = Contacts")
                        SetToolbarForNoData("Toolbar cannot be used in your Contacts folder.")
                        Cursor.Current = Cursors.Default
                        Exit Sub
                    End If

                    If explorer.CurrentFolder.Name = Exchange_UserName Then
                        WriteDebugLine(explorer.CurrentFolder.Name = "Exchange_UserName")
                        SetToolbarForNoData("Toolbar cannot be used in your Outlook Today View.")
                        Cursor.Current = Cursors.Default
                        Exit Sub
                    End If
                    If explorer.CurrentFolder.Items.Count < 1 Then
                        WriteDebugLine("explorer.CurrentFolder.Items.Count < 1")
                        SetToolbarForNoData("This is not an e-mail, Please only select a single e-mail")
                        Cursor.Current = Cursors.Default
                        Exit Sub
                    End If

                    WriteDebugLine("Get Outlook.Selection = explorer.Selection")
                    Dim selection As Outlook.Selection = Nothing
                    selection = explorer.Selection

                    If (selection Is Nothing) Then
                        WriteDebugLine("selection Is Nothing")
                        SetToolbarForNoData("This is not an e-mail, Please only select a single e-mail")
                        Cursor.Current = Cursors.Default
                        Exit Sub
                    End If

                    If selection.Count <> 1 Then
                        WriteDebugLine("selection.Count <> 1")
                        SetToolbarForNoData("This is not an e-mail, Please only select a single e-mail")
                        Cursor.Current = Cursors.Default
                        Exit Sub
                    End If


                    Dim object_ As Object
                    object_ = selection.Item(1)

                    If (object_ Is Nothing) Then
                        WriteDebugLine("object_ Is Nothing")
                        SetToolbarForNoData("This is not an e-mail, Please only select a single e-mail")
                        Cursor.Current = Cursors.Default
                        Exit Sub
                    End If

                    If object_.Class <> Outlook.OlObjectClass.olMail Then
                        WriteDebugLine("object_.Class <> Outlook.OlObjectClass.olMail")
                        SetToolbarForNoData("This is not an e-mail, Please only select a single e-mail")
                        Cursor.Current = Cursors.Default
                        Exit Sub
                    End If

                    Dim item As MailItem
                    item = object_

                    WriteDebugLine("Dim item_Sent As Boolean = item.Sent")
                    Dim item_Sent As Boolean = item.Sent
                    WriteDebugLine(item_Sent)
                    If item_Sent = False Then
                        WriteDebugLine("Toolbar cannot be updated as this e-mail has not been sent")
                        SetToolbarForNoData("Toolbar cannot be updated as this e-mail has not been sent")
                        Exit Sub
                    End If

                    If CheckWordIsEditor() = True Then
                        WriteDebugLine("CheckWordIsEditor = True")
                        If DisableToolbar = False Then
                            Connected = False
                            MsgBox("Pivotal Outlook Mail Integration has detected that Microsoft Word is set as Outlook's default e-mail editor. " & _
                            "Using word as your e-mail editor is not supported,  Please turn off Word as Outlook's e-mail editor and restart Outlook to re-enable the Pivotal Outlook Mail Integration toolbar", MsgBoxStyle.Information, "Pivotal Outlook Mail Integration Message. 0037")
                            AdxOlExplorerCmndBar.Enabled = False
                            AdxOlExplorerCmndBar.Visible = False
                            AdxOlInspectorCmdBar.Enabled = False
                            AdxOlInspectorCmdBar.Visible = False
                            Bulk_InspectorCmdBar.Enabled = False
                            Bulk_InspectorCmdBar.Visible = False
                            DisableToolbar = True
                            Cursor.Current = Cursors.Default
                        End If
                        Cursor.Current = Cursors.Default
                    End If

                    'If no system defined in options then stop and exit
                    If Pivotal_System = "<Undefined>" Then
                        WriteDebugLine("Pivotal_System = <Undefined>")
                        Exit Sub
                    End If

                    If DisableToolbar = False Then
                        If Connected = True Then

                            If Auto_Refresh = False Then
                                ClearExplorerToolbar()
                                If AdxCmdBarBtn_Refresh_EX.Visible = False Then
                                    AdxCmdBarBtn_Refresh_EX.Visible = True
                                End If
                                If AdxCmdBarBtn_Export_EX.Enabled = True Then
                                    AdxCmdBarBtn_Export_EX.Enabled = False
                                End If
                                Cursor.Current = Cursors.Default
                                Exit Sub
                            Else
                                If AdxCmdBarBtn_Refresh_EX.Visible = True Then
                                    AdxCmdBarBtn_Refresh_EX.Visible = False
                                End If
                                If AdxCmdBarBtn_Export_EX.Enabled = True Then
                                    AdxCmdBarBtn_Export_EX.Enabled = False
                                End If
                            End If

                            WriteDebugLine("Calling function: DoSelectionChange()")
                            If Employee_LtdInc <> "1" Or Employee_LtdInc <> "0" Then
                                SetEmployee_Office()
                            End If
                            ByPass_Explorer_Event = True
                            DoSelectionChange(explorer, item)
                            ByPass_Explorer_Event = False
                        Else
                            AdxOlExplorerCmndBar.Enabled = False
                            AdxOlExplorerCmndBar.Visible = False
                            AdxOlInspectorCmdBar.Enabled = False
                            AdxOlInspectorCmdBar.Visible = False
                            Bulk_InspectorCmdBar.Enabled = False
                            Bulk_InspectorCmdBar.Visible = False
                        End If
                    Else
                        AdxOlExplorerCmndBar.Enabled = False
                        AdxOlExplorerCmndBar.Visible = False
                        AdxOlInspectorCmdBar.Enabled = False
                        AdxOlInspectorCmdBar.Visible = False
                        Bulk_InspectorCmdBar.Enabled = False
                        Bulk_InspectorCmdBar.Visible = False
                    End If
                Else
                    AdxOlExplorerCmndBar.Enabled = False
                    AdxOlExplorerCmndBar.Visible = False
                    AdxOlInspectorCmdBar.Enabled = False
                    AdxOlInspectorCmdBar.Visible = False
                    Bulk_InspectorCmdBar.Enabled = False
                    Bulk_InspectorCmdBar.Visible = False
                End If
            End If
            WriteDebugLine("Finished Function: AddinModule_OlExplorerSelectionChange")
            Cursor.Current = Cursors.Default

        Catch ex As System.ApplicationException
            Connected = False
            DisableToolbar = True
            MsgBox("Pivotal Outlook Mail Integration has encountered a problem and has been disabled.  Please restart Outlook to re-enable Pivotal Outlook Mail Integration.", MsgBoxStyle.Information, "Pivotal Outlook Mail Integration Error. 0038")
            SendErrorReport("Function AddinModule_OlExplorerSelectionChange:" + Chr(13) + Chr(10) + ex.Message + Chr(13) + Chr(10) + Chr(13) + Chr(10) + ex.StackTrace)

            AdxOlExplorerCmndBar.Enabled = False
            AdxOlExplorerCmndBar.Visible = False
            AdxOlInspectorCmdBar.Enabled = False
            AdxOlInspectorCmdBar.Visible = False
            Bulk_InspectorCmdBar.Enabled = False
            Bulk_InspectorCmdBar.Visible = False
            Cursor.Current = Cursors.Default
        End Try
    End Sub


(lengthy as I have handling loads of different things:

Posted 06 Sep, 2005 04:54:44 Top
Sergey Grischenko


Add-in Express team


Posts: 7202
Joined: 2004-07-05
Hi Matt.

Try to put the folowing line into the try ... catch statement:
object_ = selection.Item(1)
I think it should prevent the error message from appearing.

E.g.

Try
object_ = selection.Item(1)
Catch
Exit Sub
End Try
Posted 06 Sep, 2005 10:24:15 Top