Group:  Microsoft Outlook » microsoft.public.outlook.program_addins
Thread: How to get Microsoft.Office.Interop.Outlook.TaskItem from the IUnknown (C#)

Geek News

How to get Microsoft.Office.Interop.Outlook.TaskItem from the IUnknown (C#)
"Godandag" <godandag[ at ]gmail.com> 4/3/2007 3:24:43 PM
Hi all.

In other words, how to implement the method GetTaskFromIntPtr in the
code below?

using Outlook = Microsoft.Office.Interop.Outlook;

...

public void Method1(Outlook.TaskItem task)
{
IntPtr ptr = Marshal.GetIUnknownForObject(task.MAPIOBJECT);
Outlook.TaskItem task1 = GetTaskFromIntPtr(ptr); //
GetTaskFromIntPtr - ?
}

public Outlook.TaskItem GetTaskFromIntPtr(IntPtr)
{
????
}

Re: How to get Microsoft.Office.Interop.Outlook.TaskItem from the IUnknown (C#)
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 4/3/2007 4:07:04 PM
If you already have a task item why are you going through hoops to get
another instance of the same task item that way? Why not just copy the
passed task item or create a new one or use NameSpace.GetItemFromID() to
retrieve another instance of the task item if you can get its EntryID
property?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Godandag" <godandag[ at ]gmail.com> wrote in message
news:1175613882.955780.135130[ at ]l77g2000hsb.googlegroups.com...
[Quoted Text]
> Hi all.
>
> In other words, how to implement the method GetTaskFromIntPtr in the
> code below?
>
> using Outlook = Microsoft.Office.Interop.Outlook;
>
> ...
>
> public void Method1(Outlook.TaskItem task)
> {
> IntPtr ptr = Marshal.GetIUnknownForObject(task.MAPIOBJECT);
> Outlook.TaskItem task1 = GetTaskFromIntPtr(ptr); //
> GetTaskFromIntPtr - ?
> }
>
> public Outlook.TaskItem GetTaskFromIntPtr(IntPtr)
> {
> ????
> }
>

Re: How to get Microsoft.Office.Interop.Outlook.TaskItem from the IUnknown (C#)
"Godandag" <godandag[ at ]gmail.com> 4/4/2007 6:33:23 AM
On 3 апр, 19:07, "Ken Slovak - [MVP - Outlook]" <kenslo...[ at ]mvps.org>
wrote:
[Quoted Text]
> If you already have a task item why are you going through hoops to get
> another instance of the same task item that way? Why not just copy the
> passed task item or create a new one or use NameSpace.GetItemFromID() to
> retrieve another instance of the task item if you can get its EntryID
> property?
>
> --
> Ken Slovak
> [MVP - Outlook]http://www.slovaktech.com
> Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
> Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm
>
> "Godandag" <godan...[ at ]gmail.com> wrote in message
>
> news:1175613882.955780.135130[ at ]l77g2000hsb.googlegroups.com...
>
> > Hi all.
>
> > In other words, how to implement the method GetTaskFromIntPtr in the
> > code below?
>
> > using Outlook = Microsoft.Office.Interop.Outlook;
>
> > ...
>
> > public void Method1(Outlook.TaskItem task)
> > {
> > IntPtr ptr = Marshal.GetIUnknownForObject(task.MAPIOBJECT);
> > Outlook.TaskItem task1 = GetTaskFromIntPtr(ptr); //
> > GetTaskFromIntPtr - ?
> > }
>
> > public Outlook.TaskItem GetTaskFromIntPtr(IntPtr)
> > {
> > ????
> > }

Hello Ken!
It is only sample. Actually, I'm trying to get updated TaskItem from
TaskRequestUpdateItem. I assume, that TaskItem is in the
olEmbeddeditem attachment of TaskRequestUpdateItem. The sequence of
operations is:

1) Get the attachment of TaskRequestUpdateItem
2) Get the PR_ATTACH_DATA_OBJ of attachment (using Extended MAPI,
IMAPIProp.OpenProperty) - so I have an IntPtr of the attachment
object. I am almost assured that there is a TaskItem. But how to wrap
it with Outlook.TaskItem interface I don't know.

I need exactly OOM Outlook.TaskItem interface (not IMessage etc.).

Re: How to get Microsoft.Office.Interop.Outlook.TaskItem from the IUnknown (C#)
"Godandag" <godandag[ at ]gmail.com> 4/4/2007 7:26:08 AM
I know, this concrete problem (get TaskRequestUpdateItem attachment as
TaskItem) can be solved like this:
Outlook.TaskRequestUpdateItem item;
....
Outlook.Attachments atts = item.Attachments;
Outlook.Attachment att = atts[1];

att.SaveAsFile("F:\\111.oft");
Outlook.TaskItem task =
(Outlook.TaskItem)ThisApplication.OlApp.CreateItemFromTemplate("F:\
\111.oft", Type.Missing);

but I don't like this way for some reason.
The way with wrapping IUnknown with the OOM interface is pleasant to
me much more.

Re: How to get Microsoft.Office.Interop.Outlook.TaskItem from the IUnknown (C#)
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 4/4/2007 1:43:37 PM
That's the way I'd do it, using a save to file.

You might want to post in the microsoft.public.win32.programmer.messaging
group with this question. It's not strictly a MAPI question, which is what
the group is for, but it's sufficiently close that the MAPI experts there
may be able to help better than we can here.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Godandag" <godandag[ at ]gmail.com> wrote in message
news:1175671568.239006.287830[ at ]o5g2000hsb.googlegroups.com...
[Quoted Text]
>I know, this concrete problem (get TaskRequestUpdateItem attachment as
> TaskItem) can be solved like this:
> Outlook.TaskRequestUpdateItem item;
> ....
> Outlook.Attachments atts = item.Attachments;
> Outlook.Attachment att = atts[1];
>
> att.SaveAsFile("F:\\111.oft");
> Outlook.TaskItem task =
> (Outlook.TaskItem)ThisApplication.OlApp.CreateItemFromTemplate("F:\
> \111.oft", Type.Missing);
>
> but I don't like this way for some reason.
> The way with wrapping IUnknown with the OOM interface is pleasant to
> me much more.
>

Re: How to get Microsoft.Office.Interop.Outlook.TaskItem from the IUnknown (C#)
"Godandag" <godandag[ at ]gmail.com> 4/5/2007 8:39:32 AM
On 4 апр, 16:43, "Ken Slovak - [MVP - Outlook]" <kenslo...[ at ]mvps.org>
wrote:
[Quoted Text]
> That's the way I'd do it, using a save to file.
>
> You might want to post in the microsoft.public.win32.programmer.messaging
> group with this question. It's not strictly a MAPI question, which is what
> the group is for, but it's sufficiently close that the MAPI experts there
> may be able to help better than we can here.
>
> --
> Ken Slovak
> [MVP - Outlook]http://www.slovaktech.com
> Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
> Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm
>
> "Godandag" <godan...[ at ]gmail.com> wrote in message
>
> news:1175671568.239006.287830[ at ]o5g2000hsb.googlegroups.com...
>
> >I know, this concrete problem (get TaskRequestUpdateItem attachment as
> > TaskItem) can be solved like this:
> > Outlook.TaskRequestUpdateItem item;
> > ....
> > Outlook.Attachments atts = item.Attachments;
> > Outlook.Attachment att = atts[1];
>
> > att.SaveAsFile("F:\\111.oft");
> > Outlook.TaskItem task =
> > (Outlook.TaskItem)ThisApplication.OlApp.CreateItemFromTemplate("F:\
> > \111.oft", Type.Missing);
>
> > but I don't like this way for some reason.
> > The way with wrapping IUnknown with the OOM interface is pleasant to
> > me much more.

Thank you, Ken.
I'll try to post in the microsoft.public.win32.programmer.messaging


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