VB6 App Notify on MS Outlook Share Calendar

Posted on 2006-03-20
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!
Question by:maonas
    LVL 76

    Expert Comment

    by:David Lee
    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.

    LVL 1

    Author Comment

    The app should be on User1's computer under user1's domain accout with MS Outlook.
    LVL 76

    Expert Comment

    by:David Lee
    Ok.  I'll get the code posted shortly (within the next 24 hours).
    LVL 76

    Accepted Solution


    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."
        End If
        Set olkNotification = Nothing
    End Sub
    'Macro Ends Here
    LVL 1

    Author Comment

    Thank you BlueDevilFan
    The solution it's great
    LVL 76

    Expert Comment

    by:David Lee
    Thank you, and you're welcome.
    LVL 1

    Author Comment

    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!

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Sometimes Outlook might have problems sending a message. There may be various causes- corrupted PST, AV scanner etc. The message, instead of going to the Sent Items folder, sits in the Outbox indefinitely. To remove it you can use a free tool cal…
    This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
    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…

    732 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

    17 Experts available now in Live!

    Get 1:1 Help Now