BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to get the "selected" item from a SharedFolder?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Freddy Rademeyer
Guest





PostPosted: Tue Jan 25, 2005 3:36 pm    Post subject: How to get the "selected" item from a SharedFolder? Reply with quote



Hi every one.

I have a need to know which item is selected in the shared folder in
Outlook. I used to following code to connect to the Calendarfolder of a
shared account.

MyApp := CreateOleObject('Outlook.Application');
NmSpace := OutlookApp.GetNamespace('MAPI');
MyRecipient := NmSpace.CreateRecipient('Jack Black');
MyRecipient.Resolve;
if MyRecipient.Resolved then
TmpFolder := NmSpace.GetSharedDefaultFolder(MyRecipient,
olFolderCalendar);


Now I can't figure out how to select the "selected" item.

If I was doing this with a normal folder the code would have been:

MyApp := CreateOleObject('Outlook.Application');
MyItem := MyApp.ActiveExplorer.Selection.Item[1];

Nice and simple.

Well I am sure someone has done something similiar.

Thanks in advance.

Freddy



Back to top
Dmitry Streblechenko
Guest





PostPosted: Tue Jan 25, 2005 7:39 pm    Post subject: Re: How to get the "selected" item from a SharedFolder? Reply with quote



A shared folder is not any different from any other folder when it is being
displayed; what's wrong with Explorer.Selection?
Since you never display the shared folder, nothing is selected - do you call
TmpFolder.Display or TmpFolder.GetExplorer?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Freddy Rademeyer" <Freddyr (AT) octagon (DOT) co.za> wrote

Quote:
Hi every one.

I have a need to know which item is selected in the shared folder in
Outlook. I used to following code to connect to the Calendarfolder of a
shared account.

MyApp := CreateOleObject('Outlook.Application');
NmSpace := OutlookApp.GetNamespace('MAPI');
MyRecipient := NmSpace.CreateRecipient('Jack Black');
MyRecipient.Resolve;
if MyRecipient.Resolved then
TmpFolder := NmSpace.GetSharedDefaultFolder(MyRecipient,
olFolderCalendar);


Now I can't figure out how to select the "selected" item.

If I was doing this with a normal folder the code would have been:

MyApp := CreateOleObject('Outlook.Application');
MyItem := MyApp.ActiveExplorer.Selection.Item[1];

Nice and simple.

Well I am sure someone has done something similiar.

Thanks in advance.

Freddy






Back to top
Freddy Rademeyer
Guest





PostPosted: Wed Jan 26, 2005 6:53 am    Post subject: Re: How to get the "selected" item from a SharedFolder? Reply with quote



Hi Dmitry,

I have a eventsink on the "OutlookItemsEvents" on the ItemRemove I have the
following code:

MyApp := CreateOleObject('Outlook.Application');
Try
MyItem := MyApp.ActiveExplorer.Selection.Item[1];
Except
on E:SysUtils.Exception do showmessage(E.Message);
end;

In the normal folder It gets the correct "selected" item, which I use to
update our DB.

Now when I run the same code for "SharedFolder" it gives me an error :
"Array index out of bounds"

So I tried using :
MyApp := CreateOleObject('Outlook.Application');
NmSpace := OutlookApp.GetNamespace('MAPI');
MyRecipient := NmSpace.CreateRecipient('Jack Black');
MyRecipient.Resolve;
if MyRecipient.Resolved then
TmpFolder := NmSpace.GetSharedDefaultFolder(MyRecipient,
olFolderCalendar);

To get the correct "SharedFolder" but when I use :
TmpFolder.Selection.Item[1] I get the following error :
"Method 'Selection' not supported by automation object"

Now I most likely have the idea incorrect. I have tried using the
TmpFolder.Display and that creates a new folder that is diaplayed. And that
tells me that I am going about this the wrong way.

All my other events works correctly in the SharedFolder except the
"ItemRemove".

Any help and suggestions welcome.

Regards,

Freddy




"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote

Quote:
A shared folder is not any different from any other folder when it is
being
displayed; what's wrong with Explorer.Selection?
Since you never display the shared folder, nothing is selected - do you
call
TmpFolder.Display or TmpFolder.GetExplorer?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Freddy Rademeyer" <Freddyr (AT) octagon (DOT) co.za> wrote in message
news:41f66787 (AT) newsgroups (DOT) borland.com...
Hi every one.

I have a need to know which item is selected in the shared folder in
Outlook. I used to following code to connect to the Calendarfolder of a
shared account.

MyApp := CreateOleObject('Outlook.Application');
NmSpace := OutlookApp.GetNamespace('MAPI');
MyRecipient := NmSpace.CreateRecipient('Jack Black');
MyRecipient.Resolve;
if MyRecipient.Resolved then
TmpFolder := NmSpace.GetSharedDefaultFolder(MyRecipient,
olFolderCalendar);


Now I can't figure out how to select the "selected" item.

If I was doing this with a normal folder the code would have been:

MyApp := CreateOleObject('Outlook.Application');
MyItem := MyApp.ActiveExplorer.Selection.Item[1];

Nice and simple.

Well I am sure someone has done something similiar.

Thanks in advance.

Freddy








Back to top
Dmitry Streblechenko
Guest





PostPosted: Wed Jan 26, 2005 6:25 pm    Post subject: Re: How to get the "selected" item from a SharedFolder? Reply with quote

1. Why do you need to create an instance of Outlook.Application again? If
you already hooked up the events, that means you already have that object,
right? Why not keep it around?
2. Do check the selection count (MyApp.ActiveExplorer.Selection.Count) first
before accessing its elements (that's what index out of bounds means).
3. Correct, MAPIFolder object does not have the Selection collection,
Explorer object does - see the interface definitions or look at the type
library
4. As I noticed before:

Explorer := TmpFolder.GetExplorer;
Explorer.Display;
if Explorer.Selection.Count > 0 then begin
...

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Freddy Rademeyer" <Freddyr (AT) octagon (DOT) co.za> wrote

Quote:
Hi Dmitry,

I have a eventsink on the "OutlookItemsEvents" on the ItemRemove I have
the
following code:

MyApp := CreateOleObject('Outlook.Application');
Try
MyItem := MyApp.ActiveExplorer.Selection.Item[1];
Except
on E:SysUtils.Exception do showmessage(E.Message);
end;

In the normal folder It gets the correct "selected" item, which I use to
update our DB.

Now when I run the same code for "SharedFolder" it gives me an error :
"Array index out of bounds"

So I tried using :
MyApp := CreateOleObject('Outlook.Application');
NmSpace := OutlookApp.GetNamespace('MAPI');
MyRecipient := NmSpace.CreateRecipient('Jack Black');
MyRecipient.Resolve;
if MyRecipient.Resolved then
TmpFolder := NmSpace.GetSharedDefaultFolder(MyRecipient,
olFolderCalendar);

To get the correct "SharedFolder" but when I use :
TmpFolder.Selection.Item[1] I get the following error :
"Method 'Selection' not supported by automation object"

Now I most likely have the idea incorrect. I have tried using the
TmpFolder.Display and that creates a new folder that is diaplayed. And
that
tells me that I am going about this the wrong way.

All my other events works correctly in the SharedFolder except the
"ItemRemove".

Any help and suggestions welcome.

Regards,

Freddy




"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote in message
news:41f6a086 (AT) newsgroups (DOT) borland.com...
A shared folder is not any different from any other folder when it is
being
displayed; what's wrong with Explorer.Selection?
Since you never display the shared folder, nothing is selected - do you
call
TmpFolder.Display or TmpFolder.GetExplorer?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Freddy Rademeyer" <Freddyr (AT) octagon (DOT) co.za> wrote in message
news:41f66787 (AT) newsgroups (DOT) borland.com...
Hi every one.

I have a need to know which item is selected in the shared folder in
Outlook. I used to following code to connect to the Calendarfolder of
a
shared account.

MyApp := CreateOleObject('Outlook.Application');
NmSpace := OutlookApp.GetNamespace('MAPI');
MyRecipient := NmSpace.CreateRecipient('Jack Black');
MyRecipient.Resolve;
if MyRecipient.Resolved then
TmpFolder := NmSpace.GetSharedDefaultFolder(MyRecipient,
olFolderCalendar);


Now I can't figure out how to select the "selected" item.

If I was doing this with a normal folder the code would have been:

MyApp := CreateOleObject('Outlook.Application');
MyItem := MyApp.ActiveExplorer.Selection.Item[1];

Nice and simple.

Well I am sure someone has done something similiar.

Thanks in advance.

Freddy










Back to top
Freddy Rademeyer
Guest





PostPosted: Thu Jan 27, 2005 8:45 am    Post subject: Re: How to get the "selected" item from a SharedFolder? Reply with quote

Hi Dmitry,

I have played with different options ... no joy.

When I use the MyApp.ActiveExplorer.Selection.Count( And I have somethings
Selected) I get 0 in the sharedfolder, but in a normal folder I get the
correct amount of selected items.

As per your recommendation I kept the instance of the "Outlook.Application"
same result(No Selected items), and I can't use the :
Explorer := TmpFolder.GetExplorer;
Explorer.Display;
if Explorer.Selection.Count > 0 then
begin
...
end

This creates a new folder that is displayed and not the one I am currently
viewing.

Now I have to say, that on all other events in the sharedfolder it is
working but not on the "ItemRemove".

And I am now clueless.

If there is any more suggestions, I am all ears.

Regards,

Freddy



"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote

Quote:
1. Why do you need to create an instance of Outlook.Application again? If
you already hooked up the events, that means you already have that object,
right? Why not keep it around?
2. Do check the selection count (MyApp.ActiveExplorer.Selection.Count)
first
before accessing its elements (that's what index out of bounds means).
3. Correct, MAPIFolder object does not have the Selection collection,
Explorer object does - see the interface definitions or look at the type
library
4. As I noticed before:

Explorer := TmpFolder.GetExplorer;
Explorer.Display;
if Explorer.Selection.Count > 0 then begin
...

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Freddy Rademeyer" <Freddyr (AT) octagon (DOT) co.za> wrote in message
news:41f73e55 (AT) newsgroups (DOT) borland.com...
Hi Dmitry,

I have a eventsink on the "OutlookItemsEvents" on the ItemRemove I have
the
following code:

MyApp := CreateOleObject('Outlook.Application');
Try
MyItem := MyApp.ActiveExplorer.Selection.Item[1];
Except
on E:SysUtils.Exception do showmessage(E.Message);
end;

In the normal folder It gets the correct "selected" item, which I use to
update our DB.

Now when I run the same code for "SharedFolder" it gives me an error :
"Array index out of bounds"

So I tried using :
MyApp := CreateOleObject('Outlook.Application');
NmSpace := OutlookApp.GetNamespace('MAPI');
MyRecipient := NmSpace.CreateRecipient('Jack Black');
MyRecipient.Resolve;
if MyRecipient.Resolved then
TmpFolder := NmSpace.GetSharedDefaultFolder(MyRecipient,
olFolderCalendar);

To get the correct "SharedFolder" but when I use :
TmpFolder.Selection.Item[1] I get the following error :
"Method 'Selection' not supported by automation object"

Now I most likely have the idea incorrect. I have tried using the
TmpFolder.Display and that creates a new folder that is diaplayed. And
that
tells me that I am going about this the wrong way.

All my other events works correctly in the SharedFolder except the
"ItemRemove".

Any help and suggestions welcome.

Regards,

Freddy




"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote in message
news:41f6a086 (AT) newsgroups (DOT) borland.com...
A shared folder is not any different from any other folder when it is
being
displayed; what's wrong with Explorer.Selection?
Since you never display the shared folder, nothing is selected - do
you
call
TmpFolder.Display or TmpFolder.GetExplorer?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Freddy Rademeyer" <Freddyr (AT) octagon (DOT) co.za> wrote in message
news:41f66787 (AT) newsgroups (DOT) borland.com...
Hi every one.

I have a need to know which item is selected in the shared folder in
Outlook. I used to following code to connect to the Calendarfolder
of
a
shared account.

MyApp := CreateOleObject('Outlook.Application');
NmSpace := OutlookApp.GetNamespace('MAPI');
MyRecipient := NmSpace.CreateRecipient('Jack Black');
MyRecipient.Resolve;
if MyRecipient.Resolved then
TmpFolder := NmSpace.GetSharedDefaultFolder(MyRecipient,
olFolderCalendar);


Now I can't figure out how to select the "selected" item.

If I was doing this with a normal folder the code would have been:

MyApp := CreateOleObject('Outlook.Application');
MyItem := MyApp.ActiveExplorer.Selection.Item[1];

Nice and simple.

Well I am sure someone has done something similiar.

Thanks in advance.

Freddy












Back to top
Dmitry Streblechenko
Guest





PostPosted: Thu Jan 27, 2005 5:06 pm    Post subject: Re: How to get the "selected" item from a SharedFolder? Reply with quote

If you want to display a folder in the current explorer: set the
Explorer.CurrentFolder property:

Application.ActiveExplorer.CurrentFolder := TmpFolder;

You get Selection.Count = 0 because nothing is selected. Are you saying that
you can see multiple messages selected, but when you query Selection.Count
you get 0? Note that if you just made an explorer visible, it might not have
a chance to initialize itself properly so the count will 0 if if you hit the
selection collection immediately.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Freddy Rademeyer" <Freddyr (AT) octagon (DOT) co.za> wrote

Quote:
Hi Dmitry,

I have played with different options ... no joy.

When I use the MyApp.ActiveExplorer.Selection.Count( And I have somethings
Selected) I get 0 in the sharedfolder, but in a normal folder I get the
correct amount of selected items.

As per your recommendation I kept the instance of the
"Outlook.Application"
same result(No Selected items), and I can't use the :
Explorer := TmpFolder.GetExplorer;
Explorer.Display;
if Explorer.Selection.Count > 0 then
begin
...
end

This creates a new folder that is displayed and not the one I am currently
viewing.

Now I have to say, that on all other events in the sharedfolder it is
working but not on the "ItemRemove".

And I am now clueless.

If there is any more suggestions, I am all ears.

Regards,

Freddy



"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote in message
news:41f7e09e$1 (AT) newsgroups (DOT) borland.com...
1. Why do you need to create an instance of Outlook.Application again?
If
you already hooked up the events, that means you already have that
object,
right? Why not keep it around?
2. Do check the selection count (MyApp.ActiveExplorer.Selection.Count)
first
before accessing its elements (that's what index out of bounds means).
3. Correct, MAPIFolder object does not have the Selection collection,
Explorer object does - see the interface definitions or look at the type
library
4. As I noticed before:

Explorer := TmpFolder.GetExplorer;
Explorer.Display;
if Explorer.Selection.Count > 0 then begin
...

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Freddy Rademeyer" <Freddyr (AT) octagon (DOT) co.za> wrote in message
news:41f73e55 (AT) newsgroups (DOT) borland.com...
Hi Dmitry,

I have a eventsink on the "OutlookItemsEvents" on the ItemRemove I
have
the
following code:

MyApp := CreateOleObject('Outlook.Application');
Try
MyItem := MyApp.ActiveExplorer.Selection.Item[1];
Except
on E:SysUtils.Exception do showmessage(E.Message);
end;

In the normal folder It gets the correct "selected" item, which I use
to
update our DB.

Now when I run the same code for "SharedFolder" it gives me an error :
"Array index out of bounds"

So I tried using :
MyApp := CreateOleObject('Outlook.Application');
NmSpace := OutlookApp.GetNamespace('MAPI');
MyRecipient := NmSpace.CreateRecipient('Jack Black');
MyRecipient.Resolve;
if MyRecipient.Resolved then
TmpFolder := NmSpace.GetSharedDefaultFolder(MyRecipient,
olFolderCalendar);

To get the correct "SharedFolder" but when I use :
TmpFolder.Selection.Item[1] I get the following error :
"Method 'Selection' not supported by automation object"

Now I most likely have the idea incorrect. I have tried using the
TmpFolder.Display and that creates a new folder that is diaplayed. And
that
tells me that I am going about this the wrong way.

All my other events works correctly in the SharedFolder except the
"ItemRemove".

Any help and suggestions welcome.

Regards,

Freddy




"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote in message
news:41f6a086 (AT) newsgroups (DOT) borland.com...
A shared folder is not any different from any other folder when it
is
being
displayed; what's wrong with Explorer.Selection?
Since you never display the shared folder, nothing is selected - do
you
call
TmpFolder.Display or TmpFolder.GetExplorer?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Freddy Rademeyer" <Freddyr (AT) octagon (DOT) co.za> wrote in message
news:41f66787 (AT) newsgroups (DOT) borland.com...
Hi every one.

I have a need to know which item is selected in the shared folder
in
Outlook. I used to following code to connect to the Calendarfolder
of
a
shared account.

MyApp := CreateOleObject('Outlook.Application');
NmSpace := OutlookApp.GetNamespace('MAPI');
MyRecipient := NmSpace.CreateRecipient('Jack Black');
MyRecipient.Resolve;
if MyRecipient.Resolved then
TmpFolder :=
NmSpace.GetSharedDefaultFolder(MyRecipient,
olFolderCalendar);


Now I can't figure out how to select the "selected" item.

If I was doing this with a normal folder the code would have been:

MyApp := CreateOleObject('Outlook.Application');
MyItem := MyApp.ActiveExplorer.Selection.Item[1];

Nice and simple.

Well I am sure someone has done something similiar.

Thanks in advance.

Freddy














Back to top
Freddy Rademeyer
Guest





PostPosted: Fri Jan 28, 2005 4:37 pm    Post subject: Re: How to get the "selected" item from a SharedFolder? Reply with quote

Hi Dmitry,

Thanks for the response,

I tried the Application.ActiveExplorer.CurrentFolder := TmpFolder, but get
the following message: "You do not have sufficient permission to perform
this operation on this object. See folder contact or your system
administrator". I have all the available rights on this shared folder, so no
no.

And to the second part: Yes I have multiple items selected in the shared
folder but when I check the Selection.count in the "ItemRemove" event I get
zero.

Perhaps I need to solve this problem from a different angle.

Let me explain what my goal is and perhaps you know of another way:

I Log all activity the user has in their outlook, like creating appointments
and tasks( I add a unique Ref to each Subject for tracking). So when they
delete items(appointments) I track that and update my DB. In this particle
case the user will be working on someone elses calendar updating their
calendar(adding and removing) appointments.

Goal: Need to update which Appointments was deleted in my DB. But if I don't
know which appointment I can't update...

Well perhaps I need to go home and tomorrow the solutions will present
itself to me...

Once again thanks a mill for the advise.

Regards,

Freddy


"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote

Quote:
If you want to display a folder in the current explorer: set the
Explorer.CurrentFolder property:

Application.ActiveExplorer.CurrentFolder := TmpFolder;

You get Selection.Count = 0 because nothing is selected. Are you saying
that
you can see multiple messages selected, but when you query Selection.Count
you get 0? Note that if you just made an explorer visible, it might not
have
a chance to initialize itself properly so the count will 0 if if you hit
the
selection collection immediately.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Freddy Rademeyer" <Freddyr (AT) octagon (DOT) co.za> wrote in message
news:41f8aa31 (AT) newsgroups (DOT) borland.com...
Hi Dmitry,

I have played with different options ... no joy.

When I use the MyApp.ActiveExplorer.Selection.Count( And I have
somethings
Selected) I get 0 in the sharedfolder, but in a normal folder I get the
correct amount of selected items.

As per your recommendation I kept the instance of the
"Outlook.Application"
same result(No Selected items), and I can't use the :
Explorer := TmpFolder.GetExplorer;
Explorer.Display;
if Explorer.Selection.Count > 0 then
begin
...
end

This creates a new folder that is displayed and not the one I am
currently
viewing.

Now I have to say, that on all other events in the sharedfolder it is
working but not on the "ItemRemove".

And I am now clueless.

If there is any more suggestions, I am all ears.

Regards,

Freddy



"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote in message
news:41f7e09e$1 (AT) newsgroups (DOT) borland.com...
1. Why do you need to create an instance of Outlook.Application again?
If
you already hooked up the events, that means you already have that
object,
right? Why not keep it around?
2. Do check the selection count (MyApp.ActiveExplorer.Selection.Count)
first
before accessing its elements (that's what index out of bounds means).
3. Correct, MAPIFolder object does not have the Selection collection,
Explorer object does - see the interface definitions or look at the
type
library
4. As I noticed before:

Explorer := TmpFolder.GetExplorer;
Explorer.Display;
if Explorer.Selection.Count > 0 then begin
...

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Freddy Rademeyer" <Freddyr (AT) octagon (DOT) co.za> wrote in message
news:41f73e55 (AT) newsgroups (DOT) borland.com...
Hi Dmitry,

I have a eventsink on the "OutlookItemsEvents" on the ItemRemove I
have
the
following code:

MyApp := CreateOleObject('Outlook.Application');
Try
MyItem := MyApp.ActiveExplorer.Selection.Item[1];
Except
on E:SysUtils.Exception do showmessage(E.Message);
end;

In the normal folder It gets the correct "selected" item, which I
use
to
update our DB.

Now when I run the same code for "SharedFolder" it gives me an error
:
"Array index out of bounds"

So I tried using :
MyApp := CreateOleObject('Outlook.Application');
NmSpace := OutlookApp.GetNamespace('MAPI');
MyRecipient := NmSpace.CreateRecipient('Jack Black');
MyRecipient.Resolve;
if MyRecipient.Resolved then
TmpFolder :=
NmSpace.GetSharedDefaultFolder(MyRecipient,
olFolderCalendar);

To get the correct "SharedFolder" but when I use :
TmpFolder.Selection.Item[1] I get the following error :
"Method 'Selection' not supported by automation object"

Now I most likely have the idea incorrect. I have tried using the
TmpFolder.Display and that creates a new folder that is diaplayed.
And
that
tells me that I am going about this the wrong way.

All my other events works correctly in the SharedFolder except the
"ItemRemove".

Any help and suggestions welcome.

Regards,

Freddy




"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote in message
news:41f6a086 (AT) newsgroups (DOT) borland.com...
A shared folder is not any different from any other folder when it
is
being
displayed; what's wrong with Explorer.Selection?
Since you never display the shared folder, nothing is selected -
do
you
call
TmpFolder.Display or TmpFolder.GetExplorer?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Freddy Rademeyer" <Freddyr (AT) octagon (DOT) co.za> wrote in message
news:41f66787 (AT) newsgroups (DOT) borland.com...
Hi every one.

I have a need to know which item is selected in the shared
folder
in
Outlook. I used to following code to connect to the
Calendarfolder
of
a
shared account.

MyApp := CreateOleObject('Outlook.Application');
NmSpace := OutlookApp.GetNamespace('MAPI');
MyRecipient := NmSpace.CreateRecipient('Jack Black');
MyRecipient.Resolve;
if MyRecipient.Resolved then
TmpFolder :=
NmSpace.GetSharedDefaultFolder(MyRecipient,
olFolderCalendar);


Now I can't figure out how to select the "selected" item.

If I was doing this with a normal folder the code would have
been:

MyApp := CreateOleObject('Outlook.Application');
MyItem := MyApp.ActiveExplorer.Selection.Item[1];

Nice and simple.

Well I am sure someone has done something similiar.

Thanks in advance.

Freddy
















Back to top
Dmitry Streblechenko
Guest





PostPosted: Sat Jan 29, 2005 1:54 am    Post subject: Re: How to get the "selected" item from a SharedFolder? Reply with quote

The problem with setting Explorer.CurrentFolder property is probably due to
Delphi unable to handle set-by-ref properties. Are you using early or late
binding?
Secondly, do *not* use events for any kind of synchronization - they are a
simple FYI, subject to be dropped under heavy loads. Plus you cannot track
deleted items - the item being deleted (already deleted actually) is not
passed to you handler.
For Exchange (that's what you are using, right?), use the special interfaces
designed for this very purpose - search for IExchangeExportChanges etc on
MSDN. The Platform SDK has a sample app that synchronizes an Exchange
folder. Essentially you will be able to ask Exchnage to play back the
changes (add/edit/delete) since the last sync cycle.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Freddy Rademeyer" <Freddyr (AT) octagon (DOT) co.za> wrote

Quote:
Hi Dmitry,

Thanks for the response,

I tried the Application.ActiveExplorer.CurrentFolder := TmpFolder, but get
the following message: "You do not have sufficient permission to perform
this operation on this object. See folder contact or your system
administrator". I have all the available rights on this shared folder, so
no
no.

And to the second part: Yes I have multiple items selected in the shared
folder but when I check the Selection.count in the "ItemRemove" event I
get
zero.

Perhaps I need to solve this problem from a different angle.

Let me explain what my goal is and perhaps you know of another way:

I Log all activity the user has in their outlook, like creating
appointments
and tasks( I add a unique Ref to each Subject for tracking). So when they
delete items(appointments) I track that and update my DB. In this particle
case the user will be working on someone elses calendar updating their
calendar(adding and removing) appointments.

Goal: Need to update which Appointments was deleted in my DB. But if I
don't
know which appointment I can't update...

Well perhaps I need to go home and tomorrow the solutions will present
itself to me...

Once again thanks a mill for the advise.

Regards,

Freddy


"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote in message
news:41f91f90$1 (AT) newsgroups (DOT) borland.com...
If you want to display a folder in the current explorer: set the
Explorer.CurrentFolder property:

Application.ActiveExplorer.CurrentFolder := TmpFolder;

You get Selection.Count = 0 because nothing is selected. Are you saying
that
you can see multiple messages selected, but when you query
Selection.Count
you get 0? Note that if you just made an explorer visible, it might not
have
a chance to initialize itself properly so the count will 0 if if you hit
the
selection collection immediately.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Freddy Rademeyer" <Freddyr (AT) octagon (DOT) co.za> wrote in message
news:41f8aa31 (AT) newsgroups (DOT) borland.com...
Hi Dmitry,

I have played with different options ... no joy.

When I use the MyApp.ActiveExplorer.Selection.Count( And I have
somethings
Selected) I get 0 in the sharedfolder, but in a normal folder I get
the
correct amount of selected items.

As per your recommendation I kept the instance of the
"Outlook.Application"
same result(No Selected items), and I can't use the :
Explorer := TmpFolder.GetExplorer;
Explorer.Display;
if Explorer.Selection.Count > 0 then
begin
...
end

This creates a new folder that is displayed and not the one I am
currently
viewing.

Now I have to say, that on all other events in the sharedfolder it is
working but not on the "ItemRemove".

And I am now clueless.

If there is any more suggestions, I am all ears.

Regards,

Freddy



"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote in message
news:41f7e09e$1 (AT) newsgroups (DOT) borland.com...
1. Why do you need to create an instance of Outlook.Application
again?
If
you already hooked up the events, that means you already have that
object,
right? Why not keep it around?
2. Do check the selection count
(MyApp.ActiveExplorer.Selection.Count)
first
before accessing its elements (that's what index out of bounds
means).
3. Correct, MAPIFolder object does not have the Selection
collection,
Explorer object does - see the interface definitions or look at the
type
library
4. As I noticed before:

Explorer := TmpFolder.GetExplorer;
Explorer.Display;
if Explorer.Selection.Count > 0 then begin
...

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Freddy Rademeyer" <Freddyr (AT) octagon (DOT) co.za> wrote in message
news:41f73e55 (AT) newsgroups (DOT) borland.com...
Hi Dmitry,

I have a eventsink on the "OutlookItemsEvents" on the ItemRemove I
have
the
following code:

MyApp := CreateOleObject('Outlook.Application');
Try
MyItem := MyApp.ActiveExplorer.Selection.Item[1];
Except
on E:SysUtils.Exception do showmessage(E.Message);
end;

In the normal folder It gets the correct "selected" item, which I
use
to
update our DB.

Now when I run the same code for "SharedFolder" it gives me an
error
:
"Array index out of bounds"

So I tried using :
MyApp := CreateOleObject('Outlook.Application');
NmSpace := OutlookApp.GetNamespace('MAPI');
MyRecipient := NmSpace.CreateRecipient('Jack Black');
MyRecipient.Resolve;
if MyRecipient.Resolved then
TmpFolder :=
NmSpace.GetSharedDefaultFolder(MyRecipient,
olFolderCalendar);

To get the correct "SharedFolder" but when I use :
TmpFolder.Selection.Item[1] I get the following error :
"Method 'Selection' not supported by automation object"

Now I most likely have the idea incorrect. I have tried using the
TmpFolder.Display and that creates a new folder that is diaplayed.
And
that
tells me that I am going about this the wrong way.

All my other events works correctly in the SharedFolder except the
"ItemRemove".

Any help and suggestions welcome.

Regards,

Freddy




"Dmitry Streblechenko" <dmitry (AT) dimastr (DOT) com> wrote in message
news:41f6a086 (AT) newsgroups (DOT) borland.com...
A shared folder is not any different from any other folder when
it
is
being
displayed; what's wrong with Explorer.Selection?
Since you never display the shared folder, nothing is selected -
do
you
call
TmpFolder.Display or TmpFolder.GetExplorer?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Freddy Rademeyer" <Freddyr (AT) octagon (DOT) co.za> wrote in message
news:41f66787 (AT) newsgroups (DOT) borland.com...
Hi every one.

I have a need to know which item is selected in the shared
folder
in
Outlook. I used to following code to connect to the
Calendarfolder
of
a
shared account.

MyApp := CreateOleObject('Outlook.Application');
NmSpace := OutlookApp.GetNamespace('MAPI');
MyRecipient := NmSpace.CreateRecipient('Jack
Black');
MyRecipient.Resolve;
if MyRecipient.Resolved then
TmpFolder :=
NmSpace.GetSharedDefaultFolder(MyRecipient,
olFolderCalendar);


Now I can't figure out how to select the "selected" item.

If I was doing this with a normal folder the code would have
been:

MyApp := CreateOleObject('Outlook.Application');
MyItem := MyApp.ActiveExplorer.Selection.Item[1];

Nice and simple.

Well I am sure someone has done something similiar.

Thanks in advance.

Freddy


















Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.