Quantcast
Channel: NetOffice - MS Office in .NET
Viewing all articles
Browse latest Browse all 1741

New Post: Outlook Explorer BeforeItemPasteEvent: Hot access the pasted item?

$
0
0
Hi,

I have an Outlook VBA project which I want to convert to a .Net addin, using NetOffice 1.7.3 and Visual Studio Express 2013. So far 90% is finished and running smoothly, but now I'm scratching my head. I'm using the BeforeItemPasteEvent:
m_objExplorer.BeforeItemPasteEvent += new Outlook.Explorer_BeforeItemPasteEventHandler(BeforeItemPasteEvent);
It passes the pasted object as COMObject:
public void TaskBeforeItemPaste(ref object ClipBoard)
In my old VBA project I could easily access this object:
Public Sub TaskBeforeItemPaste(ClipboardContent As Variant)
      
    Dim Appt As Outlook.TaskItem
    Dim t As String
    t = ClipboardContent.Item(1).MessageClass
    If t = "IPM.Task" Then
        Set Appt = ClipboardContent.Item(1)
        Appt.Role = t 'Set flag
        Appt.Save
    End If
End Sub
This easy access to the pasted item seems not to be possible with the COMObject which I get with the BeforeItemPasteEventHandler. I googled a lot and got as far as using the IDispatch interface and confirming the type of the passed object. But I'm completely out of my depth here when trying to use the IDispatch.Invoke method. Up to now I get an access violation exception. And even if I get around that, I wouldn't trust myself to write code which doesn't cause security issues, memory leaks or other problems.
Is there an easy way to get the pasted item from 'ref object ClipBoard' and change it before it's actually pasted?

TIA,
Christian

Viewing all articles
Browse latest Browse all 1741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>