Solved

Automate Out Of Office Assistant

Posted on 2002-04-18
19
276 Views
Last Modified: 2010-04-08
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
Comment
Question by:roverm
  • 10
  • 9
19 Comments
 
LVL 16

Expert Comment

by:Neo_mvps
ID: 6950552
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
 
LVL 12

Author Comment

by:roverm
ID: 6950795
I had that sample already, but can't seem to integrate that into my VBA application.
Any suggestions ?

D'Mzzl!
RoverM
0
 
LVL 16

Accepted Solution

by:
Neo_mvps earned 150 total points
ID: 6951069
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
 
LVL 12

Author Comment

by:roverm
ID: 6952672
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
 
LVL 16

Expert Comment

by:Neo_mvps
ID: 6953687
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
 
LVL 12

Author Comment

by:roverm
ID: 6954302
Because I tried to get the Outlook instance session. Didn't work obviously... ;-)

Yes, I get exactly the same error using your code.
0
 
LVL 16

Expert Comment

by:Neo_mvps
ID: 6954754
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
 
LVL 12

Author Comment

by:roverm
ID: 6954772
Yes, it's installed....
The exact error using your code is:
[E-NOINTERFACE(80004002)]

0
 
LVL 16

Expert Comment

by:Neo_mvps
ID: 6954797
Woa... what version of Outlook are you working with?
0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
LVL 12

Author Comment

by:roverm
ID: 6954890
Outlook 2000, SR-1 on a Windows 2000 Professional machine.
0
 
LVL 16

Expert Comment

by:Neo_mvps
ID: 6955373
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
 
LVL 12

Author Comment

by:roverm
ID: 6955741
Yes, I ran it while connected.
0
 
LVL 16

Expert Comment

by:Neo_mvps
ID: 6955859
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
 
LVL 12

Author Comment

by:roverm
ID: 6956613
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
 
LVL 16

Expert Comment

by:Neo_mvps
ID: 6957615
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
 
LVL 12

Author Comment

by:roverm
ID: 6957630
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
 
LVL 12

Author Comment

by:roverm
ID: 6959077
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
 
LVL 16

Expert Comment

by:Neo_mvps
ID: 6964016
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
 
LVL 12

Author Comment

by:roverm
ID: 6966551
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now