System.Runtime.InteropServices.InvalidComObjectException Raised while retrieving Outlook.MailItem

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

System.Runtime.InteropServices.InvalidComObjectException Raised while retrieving Outlook.MailItem
 
franck DAMMANN




Posts: 41
Joined: 2021-01-26
Dear all,

I developed a plugin catching every mails sent (adding a mail address in BCC), but I get an error while retrieving Outlook.MailItem on reply emails:



        public override void ProcessSend(AddinExpress.MSO.ADXCancelEventArgs e)
        {

                Outlook.MailItem mail = this.ItemObj as Outlook.MailItem;
...


I've seen that this error is raised only when we are replying on emails...
Do you know how I can retrieve MailItem in that case ?

Thanks !
Franck.
Posted 14 Mar, 2021 13:32:42 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Franck,

You should do this in the ItemSend event of the Outlook.Application object. In Add-in Express, this event is mapped to the ItemSend event of the Outlook Events component.


Andrei Smolin
Add-in Express Team Leader
Posted 15 Mar, 2021 03:02:24 Top
franck DAMMANN




Posts: 41
Joined: 2021-01-26
thanks Andrei,

I tried to include it into

        private void adxOutlookEvents_ItemSend(object sender, ADXOlItemSendEventArgs e)
        {
            Outlook.MailItem mail = e.Item as Outlook.MailItem;
            if (mail != null)
            {
                Debug.WriteLine("adxOutlookEvents_ItemSend -> Item sent !");
                
            }
        }


but this method is not called. which method you mean by
ItemSend event of the Outlook.Application object
is it the good one ?

Thanks.
Posted 15 Mar, 2021 06:16:13 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Franck,

This is the event in question.

franck DAMMANN writes:
but this method is not called.


Make sure the email gets sent. To prevent it from going out, select this Ribbon checkbox: tab Send / Receive | Send / Receive Groups | Disable Scheduled Send / Receive.


Andrei Smolin
Add-in Express Team Leader
Posted 15 Mar, 2021 07:43:19 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
And turn off all other COM add-ins.


Andrei Smolin
Add-in Express Team Leader
Posted 15 Mar, 2021 07:43:49 Top
franck DAMMANN




Posts: 41
Joined: 2021-01-26
There is no other COM add-ins installed but this method is not called after an email being sent, I tried multiple ways but the only event called after a send email is
public override void ProcessSend(AddinExpress.MSO.ADXCancelEventArgs e)
My events in AddinModule.cs is never called upon SendItem.

Is there something I missed in the configuration of my project ?
Posted 15 Mar, 2021 09:28:56 Top
franck DAMMANN




Posts: 41
Joined: 2021-01-26
The only events called are located in OutlookItemEventsClass1.cs
Posted 15 Mar, 2021 09:29:44 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Franck,

Send your project to the support email address; find the email address in readme.txt. I'll check the project today or, maybe, tomorrow.


Andrei Smolin
Add-in Express Team Leader
Posted 15 Mar, 2021 09:35:55 Top