Form in ADOlFormsManger doesn't appear sometime...

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

Form in ADOlFormsManger doesn't appear sometime...
Addin-Express Outlook 
Pillow Kwon




Posts: 3
Joined: 2018-04-02
Hi, I make some add-in that send mail with custom file attaching logic.
sequence is like this.

1) send mail with file (files are included in custorm bottom pane)
2) check mail in ItemSend Event
3) If files are attached, cancel mail send and save it. and beginning file upload
4) when files are completly uploaded, send mail.

But after doing this, compose mail window dosen't showing custom bottom pane.
If I closing window that has problem and making new compose mail window,
It works fine...

Can anybody tell me some advise about this?..
Posted 02 Apr, 2018 02:14:09 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hello Pillow,

I suppose the issue isn't reproducible if you use an ADXOlForm with no custom functionality influencing the visibility of the form.

If you have custom logic that shows/hides the ADXOlForm, then you should check and re-check it. Pay special attention to section Accessing a Form Instance at https://www.add-in-express.com/docs/net-outlook-regions-panes-ui.php#form-instances-programmatically.

I suggest that you control the visibility of the form in this way:
- in the ADXOlForm.ADXBeforeFormShow event, you set ADXOlForm.Visible=true/false depending on a condition calculated in other parts of your code
- to show the form, make sure that the condition above is true and call ADXOlForm.Show()
- to hide the form, call ADXOlForm.Hide()

Find an example demonstrating the approach above at https://www.add-in-express.com/support/addin-c-sharp.php#form-regions; see the title How to set the visibility of the form in an Outlook advanced form region.


Andrei Smolin
Add-in Express Team Leader
Posted 02 Apr, 2018 04:49:56 Top
Pillow Kwon




Posts: 3
Joined: 2018-04-02
Thanks for reply.

I should read content that you mentioned.

One more question, Is ADXOlForm has problem when
the another thread possess MAPI resource?

My code is down here, and I comment out the whole code in WhenFileUploadCompleted(),
the problem has not occured

[Code]

WhenFileUploadCompleted()
{
Outlook._NameSpace ns = OutlookApp.GetNamespace("MAPI");
Outlook.MailItem mailItem = ns.GetItemFromID(mailEntryId, Type.Missing) as Outlook.MailItem;

mailItem.Send()

~ ReleaseResources ~
}

OutlookEvents_ItemSend(ItemSendEventArgs e)
{
Outlook.MailItem mailItem = e.Item as Outlook.MailItem;
Outlook.Inspector oIns = mailItem.GetInspector;

FileAttachedForm formFileAttach = adxOlFormsManager.Items[0].GetCurrentForm(AddinExpress.OL.EmbeddedFormStates.Visible) as FileAttachedForm;

~ GetFileInfos from Form ~

AsyncFileUploadThread fileUploadThread = new AsyncFileUploadThread();
fileUploadThread.EventWhenFileUploadComplete += WhenFileUploadCompleted;
fileUploadThread.Start();

mailItem.Save();
e.Cancel = true;
oIns.Close(Outlook.OlInspectorClose.olDiscard);

~ReleaseResources ~
}
Posted 02 Apr, 2018 20:45:26 Top
Pillow Kwon




Posts: 3
Joined: 2018-04-02
I solved issue.

Thanks for helping.

The reason of problem was mailItem.Send() method makes the another
OutlookEvents_ItemSend event.

I think it causing abnormal behavior of form working ha ha ha....

Have a nice day and thank you for support once again.
Posted 03 Apr, 2018 03:11:36 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Thank you!


Andrei Smolin
Add-in Express Team Leader
Posted 03 Apr, 2018 04:27:49 Top