Grant Carthew

Hi,

I am making an Outlook Add-in for Office 2007 using VSTO 2005 SE. I am querying an SQL Server for Outlook Appointment Item details, and then creating the Appointment Items. When this process runs a typical user will end up creating anywhere from 10 to 100 Appointment Items.

This all works fine but at the moment it is visually disruptive due to the Appointment Item creation process showing each new Appointment Item. The result is a continuous flashing of Appointment Items on the screen until the process has finished.

How can I create these Appointment Items in the background so the user does not see the items being created

Here is the subroutine I am using to create the Appointment Items;

Friend Sub CreateAppointmentItem(ByVal categoryName As String, _
ByVal subject As String, _
ByVal body As String, _
ByVal startDate As Date, _
ByVal endDate As Date, _
ByVal allDayEvent As Boolean, _
ByVal location As String)

Try

'The following couple of lines are to set the start time to 9am
'and the finish time to 5pm. This is required because if you make
'an appointment item from 22nd 12am to the 23rd 12am, Outlook only adds
'the calendar item in for one day.
startDate = New DateTime(startDate.Year, startDate.Month, startDate.Day, 9, 0, 0)
endDate =
New DateTime(endDate.Year, endDate.Month, endDate.Day, 17, 0, 0)

Dim ai As Outlook.AppointmentItem
ai = Reference.GetOutlookApplication.CreateItem(Outlook.OlItemType.olAppointmentItem)
ai.Subject = subject
ai.Body = body
ai.Start = startDate
ai.End = endDate
ai.AllDayEvent = allDayEvent
ai.Location = location
ai.Categories = categoryName
ai.Display(
False)
ai.Close(Outlook.OlInspectorClose.olSave)

Catch ex As Exception
Throw ex
End Try

End Sub




Re: Visual Studio Tools for Office Create Appointment Item Hidden From User

Sue Mosher - Outlook MVP

Replace the Display and Close statements with a Save statement.



Re: Visual Studio Tools for Office Create Appointment Item Hidden From User

Grant Carthew

You little beauty, thanks Sue.

Regards,

Grant.






Re: Visual Studio Tools for Office Create Appointment Item Hidden From User

zaabdullah

Hi Grant

I am new in dotnet .I am interested in this code.

I am getting error on this. Name reference is not declared.how and where declare it.

ai = Reference.GetOutlookApplication.CreateItem(Outlook.OlItemType.olAppointmentItem)

Zaabdullah





Re: Visual Studio Tools for Office Create Appointment Item Hidden From User

Grant Carthew

Hey Zaabdullah,

I have a class that holds a reference to the Outlook application as follows;

Imports Office = Microsoft.Office.Core

Imports Microsoft.Office.Interop

''' <summary>

''' Used to reference instantiated objects.

''' </summary>

''' <remarks>

''' This class has shared methods used to access instantiated

''' objects for use throughout the DDLS Add-In.

''' </remarks>

Public Class Reference

Private Shared mOutlookApplication As Outlook.Application

Private Shared mSyncInProcess As Boolean = False

Private Shared mProgressDialogBox As ProgressDialog

''' <summary>

''' Sets the reference for the Microsoft.Office.Interop.Outlook.Application object.

''' </summary>

''' <param name="outlookApplication">Outlook Application Object.</param>

''' <remarks>

''' This subroutine is called during the Outlook Add-in startup

''' constructor to hold a reference for the active

''' Microsoft.Office.Interop.Outlook.Application object.

''' This object is used to interact with Outlook.

''' </remarks>

Public Shared Sub SetOutlookApplication(ByRef outlookApplication As Outlook.Application)

mOutlookApplication = outlookApplication

End Sub

''' <summary>

''' Returns a reference to the active Microsoft.Office.Interop.Outlook.Application object.

''' </summary>

''' <returns>Microsoft.Office.Interop.Outlook.Application</returns>

''' <remarks>

''' This is a shared function supplying a reference to the active

''' Microsoft.Office.Interop.Outlook.Application object which is used

''' to interact with Outlook.

''' </remarks>

Public Shared Function GetOutlookApplication() As Outlook.Application

Return mOutlookApplication

End Function

''' <summary>

''' Used to determine if a Synchronisation process is active.

''' </summary>

''' <value>Set to True or False as a flag for active Synchronisation processes.</value>

''' <returns>True if a Synchronisation process is active.</returns>

''' <remarks></remarks>

Public Shared Property SyncInProcess() As Boolean

Get

Return mSyncInProcess

End Get

Set(ByVal value As Boolean)

mSyncInProcess = value

End Set

End Property

''' <summary>

''' Used as a reference for the Progress Dialog Box.

''' </summary>

''' <value>An instance of the ProgressDialog class.</value>

''' <returns>Nothing if not set.</returns>

''' <remarks></remarks>

Public Shared Property ProgressDialogBox() As ProgressDialog

Get

Return mProgressDialogBox

End Get

Set(ByVal value As ProgressDialog)

mProgressDialogBox = value

End Set

End Property

End Class