HighTechTalks DotNet Forums  

Outlook-add-in: How do I catch when a new appointment has been saved?

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss Outlook-add-in: How do I catch when a new appointment has been saved? in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
M O J O
 
Posts: n/a

Default Outlook-add-in: How do I catch when a new appointment has been saved? - 10-25-2007 , 07:16 AM






Hi,

From an vb.net-outlook-add-in ... how do I catch an event telling when
an appointment has been saved?

Thanks!!

M O J O

Reply With Quote
  #2  
Old   
Jialiang Ge [MSFT]
 
Posts: n/a

Default RE: Outlook-add-in: How do I catch when a new appointment has been saved? - 10-26-2007 , 12:43 AM






Hello M O J O,

From your post, my understanding on this issue is: you want to know how to
capture the Save event of an Outlook.AppointmentItem object. If I'm off
base, please feel free to let me know.

To capture the Save event of an Outlook.AppointmentItem object, we need to
register the Outlook.Appointment.Write event. According to the MSDN article
http://msdn2.microsoft.com/en-us/lib...ffice.11).aspx and
http://msdn2.microsoft.com/en-us/library/bb175138.aspx
The Write event occurs when an appointment is saved, either explicitly (for
example, using the Save or SaveAs method) or implicitly (for example, in
response to a prompt when closing the item's inspector).

Below is my test code of the event with VB.NET:

Imports Outlook = Microsoft.Office.Interop.Outlook

Public Class Form1

Public WithEvents appointment As Outlook.AppointmentItem

Private Sub appointment_Write(ByRef Cancel As Boolean) Handles
appointment.Write
MessageBox.Show("write")
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim appItem As Outlook.Application = New Outlook.Application()
appointment =
appItem.CreateItem(Outlook.OlItemType.olAppointmen tItem)
appointment.Subject = "test"
appointment.Body = "test"
appointment.Save()
End Sub
End Class

The appointment object registers the Write event and show a message box
"write" when the appointment is saved (appointment.Save())

Please have a try and let me know the result. If you have any other concern
or need anything else, please feel free to let me know.

Sincerely,
Jialiang Ge (jialge (AT) online (DOT) microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #3  
Old   
M O J O
 
Posts: n/a

Default Re: Outlook-add-in: How do I catch when a new appointment has beensaved? - 10-26-2007 , 01:27 AM



Hi Jialiang,

Once again you come to my rescue ... and THANKS!!!!

Here's my solution....

Private Sub OnNewInspector(ByVal inspector As Outlook.Inspector)
If TypeOf (inspector.CurrentItem) Is Outlook.AppointmentItem Then
AddHandler CType(inspector.CurrentItem,
Outlook.AppointmentItem).write, AddressOf _appItem_Write
End If
End Sub

Private Sub appointmentItem_Write(ByRef Cancel As Boolean)
Dim app As Outlook.AppointmentItem =
CType(Application.ActiveInspector.CurrentItem, Outlook.AppointmentItem)
' Do something with app!
MsgBox("YEHA")
End Sub


THANKS!!!!

))

M O J O

Jialiang Ge [MSFT] skrev:
Quote:
Hello M O J O,

From your post, my understanding on this issue is: you want to know how to
capture the Save event of an Outlook.AppointmentItem object. If I'm off
base, please feel free to let me know.

To capture the Save event of an Outlook.AppointmentItem object, we need to
register the Outlook.Appointment.Write event. According to the MSDN article
http://msdn2.microsoft.com/en-us/lib...ffice.11).aspx and
http://msdn2.microsoft.com/en-us/library/bb175138.aspx
The Write event occurs when an appointment is saved, either explicitly (for
example, using the Save or SaveAs method) or implicitly (for example, in
response to a prompt when closing the item's inspector).

Below is my test code of the event with VB.NET:

Imports Outlook = Microsoft.Office.Interop.Outlook

Public Class Form1

Public WithEvents appointment As Outlook.AppointmentItem

Private Sub appointment_Write(ByRef Cancel As Boolean) Handles
appointment.Write
MessageBox.Show("write")
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim appItem As Outlook.Application = New Outlook.Application()
appointment =
appItem.CreateItem(Outlook.OlItemType.olAppointmen tItem)
appointment.Subject = "test"
appointment.Body = "test"
appointment.Save()
End Sub
End Class

The appointment object registers the Write event and show a message box
"write" when the appointment is saved (appointment.Save())

Please have a try and let me know the result. If you have any other concern
or need anything else, please feel free to let me know.

Sincerely,
Jialiang Ge (jialge (AT) online (DOT) microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.