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

VB6 App Notify on MS Outlook Share Calendar

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!
0
maonas
Asked:
maonas
  • 4
  • 3
1 Solution
 
David LeeCommented:
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!
0
 
maonasAuthor Commented:
The app should be on User1's computer under user1's domain accout with MS Outlook.
0
 
David LeeCommented:
Ok.  I'll get the code posted shortly (within the next 24 hours).
0
Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

 
David LeeCommented:
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
0
 
maonasAuthor Commented:
Thank you BlueDevilFan
The solution it's great
0
 
David LeeCommented:
Thank you, and you're welcome.
0
 
maonasAuthor 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!
0

Featured Post

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.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now