Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Reading (Displaying) MailItem with Custom Form

Geek News

Reading (Displaying) MailItem with Custom Form
Paulem0071 11/21/2008 10:02:01 PM
Does anyone have any experience displaying an existing MailItem with a custom
MessageClass?

When I filter and retrieve an affected Mailtem, I get an
DISP_E_MEMBERNOTFOUND exception when calling mailitem.Display(false)

Here is a code excerpt:

string filter = [ at ]"[ at ]SQL=(""urn:schemas:httpmail:subject"" like '%test%' ";
filter = filter + [ at ]" AND
""http://schemas.microsoft.com/mapi/proptag/0x001a001e"" =
'IPM.Note.Special.Note)";

Outlook.Items items = (Outlook.Items)folder.Items.Restrict(filter);

foreach (object o in items)
{

OutlookMailItem f = o as Outlook.MailItem;
//this fails with DISP_E_MEMBERNOTFOUND
f.GetInspector.Display(false);

//so does this
f.Display(false);
//just do one
break;
}

Thanks a lot.

Re: Reading (Displaying) MailItem with Custom Form
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 11/24/2008 3:09:55 PM
Is that a typo with the missing single quote after the name of your custom
MessageClass? Have you checked the returned restricted Items collection to
see if the items.Count property is greater than 0?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Paulem0071" <Paulem0071[ at ]discussions.microsoft.com> wrote in message
news:5A62D0F8-57E2-41CC-8EC7-AE5BE7F9960A[ at ]microsoft.com...
[Quoted Text]
> Does anyone have any experience displaying an existing MailItem with a
> custom
> MessageClass?
>
> When I filter and retrieve an affected Mailtem, I get an
> DISP_E_MEMBERNOTFOUND exception when calling mailitem.Display(false)
>
> Here is a code excerpt:
>
> string filter = [ at ]"[ at ]SQL=(""urn:schemas:httpmail:subject"" like '%test%'
> ";
> filter = filter + [ at ]" AND
> ""http://schemas.microsoft.com/mapi/proptag/0x001a001e"" =
> 'IPM.Note.Special.Note)";
>
> Outlook.Items items = (Outlook.Items)folder.Items.Restrict(filter);
>
> foreach (object o in items)
> {
>
> OutlookMailItem f = o as Outlook.MailItem;
> //this fails with DISP_E_MEMBERNOTFOUND
> f.GetInspector.Display(false);
>
> //so does this
> f.Display(false);
> //just do one
> break;
> }
>
> Thanks a lot.
>

Re: Reading (Displaying) MailItem with Custom Form
Paulem0071 12/1/2008 3:48:11 PM
Yes, that is a typo.

Also, I am getting objects returned.

Is the proper way to display a mail tiem (that is, open it as if you double
clicked on the message in the inbox), Outlook.Mailitem.Display(bool)?

Thank you.



"Ken Slovak - [MVP - Outlook]" wrote:

[Quoted Text]
> Is that a typo with the missing single quote after the name of your custom
> MessageClass? Have you checked the returned restricted Items collection to
> see if the items.Count property is greater than 0?
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.
> http://www.slovaktech.com/products.htm
>
>
> "Paulem0071" <Paulem0071[ at ]discussions.microsoft.com> wrote in message
> news:5A62D0F8-57E2-41CC-8EC7-AE5BE7F9960A[ at ]microsoft.com...
> > Does anyone have any experience displaying an existing MailItem with a
> > custom
> > MessageClass?
> >
> > When I filter and retrieve an affected Mailtem, I get an
> > DISP_E_MEMBERNOTFOUND exception when calling mailitem.Display(false)
> >
> > Here is a code excerpt:
> >
> > string filter = [ at ]"[ at ]SQL=(""urn:schemas:httpmail:subject"" like '%test%'
> > ";
> > filter = filter + [ at ]" AND
> > ""http://schemas.microsoft.com/mapi/proptag/0x001a001e"" =
> > 'IPM.Note.Special.Note)";
> >
> > Outlook.Items items = (Outlook.Items)folder.Items.Restrict(filter);
> >
> > foreach (object o in items)
> > {
> >
> > OutlookMailItem f = o as Outlook.MailItem;
> > //this fails with DISP_E_MEMBERNOTFOUND
> > f.GetInspector.Display(false);
> >
> > //so does this
> > f.Display(false);
> > //just do one
> > break;
> > }
> >
> > Thanks a lot.
> >
>
>
Re: Reading (Displaying) MailItem with Custom Form
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 12/2/2008 2:25:10 PM
Yes, Mailitem.Display(bool) is correct and you really should only use false
as your bool value. Modal Inspectors usually cause various problems.

That error you get (DISP_E_MEMBERNOTFOUND) is usually a C++ type error that
occurs when there are problems with an IDispatch pointer, so I'm not sure
why you'd see it with C# code. It would indicate that there are 0 members
but that can't be if your restricted Items collection's Count property is
greater than 0, or that an attempt to set a read-only property was made.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Paulem0071" <Paulem0071[ at ]discussions.microsoft.com> wrote in message
news:28A56072-CEEE-4927-947B-80497A12120D[ at ]microsoft.com...
[Quoted Text]
> Yes, that is a typo.
>
> Also, I am getting objects returned.
>
> Is the proper way to display a mail tiem (that is, open it as if you
> double
> clicked on the message in the inbox), Outlook.Mailitem.Display(bool)?
>
> Thank you.

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net