wmgroup
Guest
|
I've posted before about this but never got it figured out. How do I get the name of the form from a form that is being closed? I have a two forms in project one contains some form fields I need to check if the email is closed that has that form on it. How do I get the form name in the ProcessClose? Example? |
|
Dmitry Kostochko
Add-in Express team
Posts: 2875
Joined: 2004-04-05
|
Hi William,
As far as I understand, you have added an advanced Outlook form region (via the ADXOlFormsManager component) to the Outlook Inspector window, correct? If so, I think you can try to use the ADXOutlookAppEvents.InspectorClose event, please see the code sample below:
private void adxOutlookAppEvents1_InspectorClose(object sender, object inspector, string folderName)
{
Outlook._Inspector insp = inspector as Outlook._Inspector;
if (insp != null)
{
object objItem = insp.CurrentItem;
if (objItem != null)
try
{
Outlook._MailItem mail = objItem as Outlook._MailItem;
if (mail != null)
{
// find our advanced form (Inspector window)
ADXOlForm1 myInspectorForm = adxOlFormsCollectionItem1.GetForm(insp) as ADXOlForm1;
if (myInspectorForm != null)
{
// get value from text box
System.Diagnostics.Debug.WriteLine("+++ InspectorClose! " + myInspectorForm.textBox1.Text);
}
}
}
finally { Marshal.ReleaseComObject(objItem); }
}
}
|
|
wmgroup
Guest
|
Thanks, that seems like it would work but if I don't know which form it could be that is closing how can I cast the right one here? I have two different forms that can be shown depending on if new email or opening an email.
ADXOlForm1 myInspectorForm = adxOlFormsCollectionItem1.GetForm(insp) as ADXOlForm1;
If I know the exact form that I'm closing I can get it to work but there are two forms.
This works when I am closing the form selectemailform
SelectEmailForm adxForm = adxOlFormsCollectionItem2.GetForm(insp) as SelectEmailForm;
and if I'm closing Sendmail form then I can use this
SendMail adxForm = adxOlFormsCollectionItem3.GetForm(insp) as SendMail;
do I just need to do both and which ever is null ignore? |
|
Dmitry Kostochko
Add-in Express team
Posts: 2875
Joined: 2004-04-05
|
Hi William,
do I just need to do both and which ever is null ignore?
I think a better approach is to check the Sent property of the _MailItem interface and call GetForm() accordingly. |
|