We help IT Professionals succeed at work.

VB6 App Notify on MS Outlook Share Calendar

maonas
maonas asked
on
Medium Priority
547 Views
Last Modified: 2010-04-08
Hi there,
I have the scenario:
- User1 have a MS Outlok Shared Calendar
- User2 have rights to access the calendar and read/write rights
I want to make an app in VB6 that wil do: when User2 do something in the User1 calendar (e.g.: create an appointment) User1 (calendar owner) will be automaticly notified by email.

Please tell me who can I do this.
Thank you very much!
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2010

Commented:
Hi maonas,

Yes, this is possible, but there's an issue you need to be aware of.  Sending email from code will trigger Outlook's built-in security causing a dialog-box to pop up warning that a program is accessing the maibox and asking for permission to continue.  The only way around this is to use a third-party tool.  Also, where do you plan to run this application at?  If it's not on User1 or User2's computer, then the computer it's on will have to have Outlook, be connected to User1's profile, and potentially know User1's password.

Cheers!

Author

Commented:
The app should be on User1's computer under user1's domain accout with MS Outlook.
CERTIFIED EXPERT
Top Expert 2010

Commented:
Ok.  I'll get the code posted shortly (within the next 24 hours).
CERTIFIED EXPERT
Top Expert 2010
Commented:
maonas,

Here's the code.  I haven't had an opportunity to test it with another user, but it should work.  I'm concerned that it might also notify User1 any time they accept an appointment from another user.  Try it out and let me know.  I changed one thing from your original request.  Instead of sending an email from User1 to User1 notify him/her that an item's been added to the calendar, I added a new post to User1's Inbox.  Follow these instructions to put the code into use.

1.  Start Outlook.
2.  Click Tools->Macros->Visual Basic Editor.
3.  If not already expanded, expand Microsoft Office Outlook Objects and select ThisOutlookSession.
4.  Copy the code and paste it into the right-hand pane of the VB editor.
5.  Click the diskette icon on the toolbar to save the code.
6.  Close the VB editor.
7.  Click Tools->Macros->Security.
8.  Change the security level to Medium.
9.  Click Ok.
10.  Close Outlook.
11.  Start Outlook.
12.  You'll receive a dialog-box telling you that ThisOutlookSession contains macros and asking if you want to enable them.  Click Enable Macros.
13.  Have User2 add an appointment to User1's calendar.


'Macro Begins Here
Private WithEvents olkCalendar As Outlook.Items

Private Sub Application_Startup()
    Set olkCalendar = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar).Items
End Sub

Private Sub Application_Quit()
    Set olkCalendar = Nothing
End Sub

Private Sub olkCalendar_ItemAdd(ByVal Item As Object)
    Dim olkNotification As Outlook.PostItem
    If Item.Organizer <> Session.CurrentUser Then
        Set olkNotification = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items.Add(olPostItem)
        olkNotification.Subject = "New Appointment Added to Your Calendar"
        olkNotification.Body = Item.Organizer & " has added a new appointment to your calendar."
        olkNotification.Save
    End If
    Set olkNotification = Nothing
End Sub
'Macro Ends Here

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Thank you BlueDevilFan
The solution it's great
CERTIFIED EXPERT
Top Expert 2010

Commented:
Thank you, and you're welcome.

Author

Commented:
I think i have a problem when User2 add an appointment to User1's calendar the item.Organizer from Private Sub olkCalendar_ItemAdd(ByVal Item As Object) is "User1" not "User2".

Please help!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.