I am new to Outlook object model. I want to trap some events like selectionchange events etc. What I found that in the selection object it returns the system.object. I have to do type checking for each item type. Not sure if there is any better way to do this.
I don't want to do type checking every time.
Ashwin
As far as I know there is no base class for outlook message item
Check this out http://outlookitemwrapper.codeplex.com/.
You can use this wrapper. Hope this would be helpful
Why not use late binding and check the Class property? Every Outlook object exposes it.
Related
Is it possible to execute some C# code when checking the "Is Approved" checkbox for a Member?
Our site has a registration form which programmatically creates a user in the Members section, however the new Members must be approved by an admin and we would like to send an email to the Member when they are approved.
I think what you will need to do is look at MemberService.Saving and MemberService.Saved events and attach a custom event handler. See Determining if an entity is new for information on determining if you are dealing with a new or existing member. Below is copied from documentation:
In v6.2+ and 7.1+ you can use the extension method on any implementation of IEntity (which is nearly all models returned by the Umbraco Services):
var isNew = entity.IsNewEntity();
How it works
This is all possible because of the IRememberBeingDirty interface. Indeed the name of this interface is hilarious but it describes exactly what it does. All entities implement this interface which is extremely handy as it tracks not only the property data that has changed (because it inherits from yet another hilarious interface called ICanBeDirty) but also the property data that was changed before it was committed.
From here you should be able to check the property data you are interested in and send your email accordingly.
If I have a class in VB6, with some events
Public Event SomethingHappened
and I later want to fire that event
RaiseEvent SomethingHappened
This works fine, in my form which is hosting the class
Public WithEvents TheObject as MyClass
...
Public Sub TheObject_SomethingHappened
...
BUT, is there any way to tell in the code which Raises the event, whether the event has been assigned a handler?
Because I would like to do some default behaviour if not.
I see that in VB.NET there is a automatic "SomethingHappenedEvent" variable declared, but that doesn't seem to work in VB6.
I can't find any mention of this on Google, so I suspect it's not possible, but...
As I mentioned in a comment, Microsoft has often dealt with this in its controls and classes by passing a ByRef Boolean "cancel default action" argument to the event handler.
If the handler exist without setting Cancel = True before returning then a default action is taken by the component.
That could be taken as a viable pattern based on established use. There may be alternatives but this seems pretty simple and clean to implement when you have events where you want to offer default actions.
I want to create a subscriber that gets triggered when the user tries to access the resource (which is a custom content-type). So, the object is not being added, modified, nothing, is just being traversed. Something like a Zope View Event.
So, basically, suppose a custom content type has a custom workflow (two states: private and viewed). The initial state is private. This content type is only going to be created programatically, using _createObjectByType by anonymous users. Suppose an object called myobjet was added, programatically, to the root folder of my Plone site.
What I want is: when the user access
http://localhost:8080/Plone/myobject
...it automatically changes the state of the workflow of this object to viewed. The url http://localhost:8080/Plone/myobject is going to be a custom view, not the default base_edit.
Which event should I use? I tried IEndRequestEvent and IBeforeTraverseEvent from this list and none of them work: the handler is not being called for my custom object interface.
I've tried other events with my custom object interface (like IObjectEditedEvent), and, for this event, my handler is called when I edit an object that implements the interface. But using IEndRequestEvent and IBeforeTraverseEvent doesn't call the handler.
IEndRequestEvent and IBeforeTraverseEvent only work when I set the subscriber to all interfaces:
<subscriber
for="*
zope.app.publication.interfaces.IBeforeTraverseEvent"
handler=".subscriber.myhandler"
/>
And when I make myhandler print the object and the event in this situation, it shows:
<PloneSite at Plone>
<zope.app.publication.interfaces.BeforeTraverseEvent object at 0xd52618c>
If the solution is to write an event myself, is there an easy tutorial for this?
You might want to have a look at http://pypi.python.org/pypi/plone.validatehook.
Make sure you bind the event to the right interface. If you bind it to "Interface" (as described on the plone.validatehook pypi page) the event will get called for every single request. In order to restrict the event to contentish objects you can do the following:
from Products.CMFCore.interfaces import IContentish
#adapter(IContentish, IPostValidationEvent)
def RedirectMember(object, event):
...
(Edit: I removed my first answer because it didn't work)
Not sure what this subscriber is supposed to do, but if the object is not being modified, added or whatsoever than I must suspect it will just be viewed...so why not just use the __call__ method of the items view (or the __update__ method if you are using five.grok/dexterity)?
In a Windows Phone 7 app, the PhoneApplicationService.Current.State object is declared as an IDictionary, and is implemented as a Dictionary. I was really hoping to get notified when any state changes occur. (I realise I could build my own state collection somewhere else and do whatever I want, but I'm retrofitting this into existing code.)
Is there any way to get that State object set to an ObservableDictionary instead of a Dictionary, so I can attach to it and get notified when the collection changes?
I'm guessing the answer will be 'no' but just want to check I haven't missed something :)
Thanks,
John
You can't change the existing implementation, but you could create a wrapper class which implements IObservable but uses PhoneApplicationService.Current.State internally.
This way, you wouldn't have to build a complete state persistence soution yourself and could implement the ObservableDictionary as best meets your needs.
I'm writing a countdown timer and instead of calling -[NSTextField setDoubleValue:secondsRemaining] on each tick, I'd like to bind the secondsRemaining property to an interface element via an object controller.
The problem with this is that secondsRemaining is modified by code on each tick, not by the interface, so the change is doesn't seem to be broadcast.
I have two parts to the question:
1) Is this a sensible way to use bindings or should I stick with -[NSTextField setDoubleValue:] in my App controller?
2) If I do use bindings, how do inform the interface that the value has changed?
Thanks!
Either use a KVO-compliant setter or send manual notifications when you mutate the value.