• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

Automate Out Of Office Assistant

Hi all!

I want to turn the Out Of Office assistant on and off throught code, based on the Calender. All CLIENT side.

I built the code for trapping the Appointment_Reminder event, but can't find the method to actually turn the OOA on/off.

D'Mzzl!
RoverM
0
roverm
Asked:
roverm
  • 10
  • 9
1 Solution
 
Neo_mvpsCommented:
The OOA is not exposed in the Outlook Object Model, but is exposed through Collaboration Data Objects.  See http://www.cdolive.com/outofofficecalendar.htm for a code sample.
0
 
rovermAuthor Commented:
I had that sample already, but can't seem to integrate that into my VBA application.
Any suggestions ?

D'Mzzl!
RoverM
0
 
Neo_mvpsCommented:
Should be as simple as...

Set oSession = CreateObject("MAPI.Session")
oSession.Logon "","",false, false

oSession.OutOfOffice = True
oSession.OutOfOfficeText = "Whatever you want the body to say."

oSession.Logoff

Set oSession = Nothing


Note: Collaboration Data Objects is not installed by default under Outlook 2000 or 2002.  It is installed by default under Outlook 98 and doesn't come with Outlook 97.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
rovermAuthor Commented:
Unfortunally not......

On the line Set oSession I get an error:
"Internal Application Error". CDO is installed.

Also, in VBA I tried this:

Set oMAPI = Outlook.GetNameSpace("MAPI")
Set oSession = oMAPI.Session

to get the session object.
But then the OutOfOffice property is not supported (Object doesn't support...)

D'Mzzl!
RoverM
0
 
Neo_mvpsCommented:
Why are you trying to shove the Outlook namespace into a cdo session object?  Also, do you get the same error using my code snippet?
0
 
rovermAuthor Commented:
Because I tried to get the Outlook instance session. Didn't work obviously... ;-)

Yes, I get exactly the same error using your code.
0
 
Neo_mvpsCommented:
odd... check to see if you have CDO.DLL on your system.  If so, do a regsvr32 on it to see if you just need the registry refreshed.
0
 
rovermAuthor Commented:
Yes, it's installed....
The exact error using your code is:
[E-NOINTERFACE(80004002)]

0
 
Neo_mvpsCommented:
Woa... what version of Outlook are you working with?
0
 
rovermAuthor Commented:
Outlook 2000, SR-1 on a Windows 2000 Professional machine.
0
 
Neo_mvpsCommented:
weird... Outlook 2000 is configured in Corporate/Workgroup and you are connected to a microsoft exchange server at the time of running this code?
0
 
rovermAuthor Commented:
Yes, I ran it while connected.
0
 
Neo_mvpsCommented:
Hmmm...  Here are some of the things I would try.

1) Uninstall/Reinstall Collaboration Data Objects
2) Change the logon method to:

oSession.Logon "Profile Name", "Password", False, False
0
 
rovermAuthor Commented:
Hi Neo_mvps!

Very sorry, but your solution worked after all!
I dunno why the first time not, but just tried it again and it worked perfectly!

The only difference now is that I tried from home using a dial up connection to work. The first time I was in the office. Will check it there again also on Monday.

Thanks for your help!

One other question (if you know I will open a new question about this):
I can't seem to find the event when an appointment is finished. What I have done now is programmaticly add a new appointment at the end of the *real* appointment and trap the reminder event.
Is there a better way to do this ? Can you trap the "Appointment_End"-event ?

D'Mzzl!
RoverM

btw:Increased points to 150
0
 
Neo_mvpsCommented:
hmm... since there isn't an appointment end event, the best I can think of is the following.

1) you catch the application_reminder event.
2) this event gives you a reference to the object that is firing it.
3) if the object is an appointmentitem, then review whichever properties you need (e.g. see if you are working with a reccuring item, etc.) and then go from there.
0
 
rovermAuthor Commented:
This is what I am doing now.
Unfortunally there's no timer orso available. Yes, I could do that via API (SetTimer) but don't want to do that.
I guess I will stick with creating another appointment at the end of the real one.

I just wanted to know another thing:
I want to use some variables orso that will retain even when Outlook is shut down. So, the next time Outlook starts read those values again, like custom properties. Don't want to use GetSetting/SaveSetting to the registry. Any ideas on that (will open another question....... ;-) )

D'Mzzl!
RoverM
0
 
rovermAuthor Commented:
k, found out what the problem was at work:

The CDO.DLL was installed, but not registered ok and couldn't be registered manually! (couldn't load library)

But by setting a reference to this library in VBA in Outlook, then remove the reference the library was loaded correct!

At home it worked because I used my laptop and at work my desktop machine....

D'Mzzl!
RoverM
0
 
Neo_mvpsCommented:
The vba environment in outlook wasn't designed to have values persist in memory between different macro runs, so the only thing you could do is save the items into the registry via the win32api* or use get/savesetting.


/Neo

* Many VB sites have great examples on how to use the win32 api to read/write values from the registry.  one that sticks out in my head is vbaccelerator.
0
 
rovermAuthor Commented:
Thanks Neo!
I do know how to read and write from/to the registry, but I prefer not to use that.

Will let you know what my solution will be.

Thanks!

D'Mzzl!
RoverM
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 10
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now