Outlook addin - how to tell an email is created from window explorer file->send to->mail recipient?

Joined
Mar 10, 2016
Messages
1
Reaction score
0
I am writing an outlook addin using c#.

The addin will work on the ItemSend event of inspector. In the event handler code, I will cancel the operation, then start a thread to process the mail, then close the mail. In the thread code, I call the send command on the mailitem.

My addin code works for email created from outlook explorer.

However when user tries to send files from window explorer by selecting "send to" then "mail recipient" command, a new email is created with files added as attachment. When user clicks send button on the mail, my addin code will fail to send the mail due to exception "System.Runtime.InteropServices.COMException (0x80004005): This item is no longer valid because it has been closed."

My question: How can I tell that this email is created by window file explorer, not outlook explorer in my addin code?

Thanks!
 
Joined
Mar 30, 2016
Messages
2
Reaction score
0
Hi,
If it's a "send to" Email when you do a Item.Copy you get an error ! you can catch this .

And if you cancel the itemsend event the Email inspector stay open and block other outlook operations.

May be with a timer you can close the currentinspector .

this is example in VB
Code:
Private Sub objOLApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Cancel = Fire_ItemSend(Item, Cancel)
    If ItemSendCancel Or Cancel Then
        Cancel = True
        Dim CopyMail As Object
        On Error Resume Next
        Set CopyMail = Item.Copy
        If Err.Number = -2147221246 Then
        'SEND TO BY EXPLORER or OTHER OFFICE APPLICATION
        On Error GoTo 0
            Item.Save

        Else
            CopyMail.Display
            Item.Delete
        End If

        Exit Sub
    End If
End Sub
 

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