Outlook send E-Mail from docked Mailwindow failed

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

Outlook send E-Mail from docked Mailwindow failed
 
300bar




Posts: 7
Joined: 2014-04-19
Sending mail from a docked sendform of outlook doesn't work.

Error in event adxOutlookEvents.ItemSend "Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt."

What can we do to handle send from a docked sendform.
www.bsc-computer.de
www.sms-ware.de
www.safesender.de
Posted 17 Sep, 2018 07:53:29 Top
Andrei Smolin


Add-in Express team


Posts: 18810
Joined: 2006-05-11
Hello 300bar,

300bar writes:
Error in event adxOutlookEvents.ItemSend "Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt."


I assume the exception occurs in your code. Is this so?


Andrei Smolin
Add-in Express Team Leader
Posted 17 Sep, 2018 10:00:41 Top
300bar




Posts: 7
Joined: 2014-04-19
I assume the exception occurs in your code. Is this so?

correct :-)
We open an additional form before sending to ask the user some things.
If Outlook Sendform is docked we crash.

Is there a workaround?
Or how can we identify, if Outlook Sendform is docked?
www.bsc-computer.de
www.sms-ware.de
www.safesender.de
Posted 18 Sep, 2018 05:10:59 Top
Andrei Smolin


Add-in Express team


Posts: 18810
Joined: 2006-05-11
Hello,

If so, what code line produces the exception?


Andrei Smolin
Add-in Express Team Leader
Posted 18 Sep, 2018 05:18:55 Top
300bar




Posts: 7
Joined: 2014-04-19
after .showdialog of a new form and executing form.load
The form is a little bit more than a messagebox.
Nothing special, nothing using addin express.
www.bsc-computer.de
www.sms-ware.de
www.safesender.de
Posted 18 Sep, 2018 06:38:59 Top
Andrei Smolin


Add-in Express team


Posts: 18810
Joined: 2006-05-11
Could you please show some code? I'll try to reproduce the issue. I don't think creating and showing a form may depend on whether some other form is docked or not.


Andrei Smolin
Add-in Express Team Leader
Posted 18 Sep, 2018 10:24:26 Top
300bar




Posts: 7
Joined: 2014-04-19
don't think creating and showing a form may depend on whether some other form is docked or not.

You are right. My Form isn't the problem.

Now I have found the chrash point.


Dim inspector As Outlook._Inspector = OutlookApp.ActiveInspector()
Dim _mailmessage As Outlook.MailItem
 If TypeOf inspector.CurrentItem Is Outlook._MailItem Then
           _mailmessage = TryCast(inspector.CurrentItem, Outlook._MailItem)
  End if 


crash at "_mailmessage = TryCast(inspector.CurrentItem, Outlook._MailItem)"
www.bsc-computer.de
www.sms-ware.de
www.safesender.de
Posted 19 Sep, 2018 03:01:20 Top
Andrei Smolin


Add-in Express team


Posts: 18810
Joined: 2006-05-11
Every object returned by a call to the Outlook object model (any Office object model) is a COM object. Performing the same call twice produces two COM objects. Your code fragment should be rewritten as follows:

Dim inspector As Outlook._Inspector = OutlookApp.ActiveInspector() 
Dim item as Object = inspector.CurrentItem
if item IsNot Nothing then
    Dim _mailmessage As Outlook.MailItem 
    If TypeOf item Is Outlook._MailItem Then 
        _mailmessage = TryCast(item, Outlook._MailItem) 
        '' Use _mailmessage here
    End if
    Marshal.ReleaseComObject(item)
    item = Nothing
End if 


Pa attention: item and _mailmessage above refer to the same object. This is why you only need to release item.

You wrote that this occurs in the ItemSend event. If so, the event handler provides the item being sent: see the parameters of the event handler. Note that Add-in Express relies on the state of all objects passed to you in parameters of Add-in Express events: you must not release them.


Andrei Smolin
Add-in Express Team Leader
Posted 19 Sep, 2018 03:29:13 Top