Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Microsoft Outlook 2007 Calendar importing (Read 8460 times)
APEXnow
YaBB Newbies
*
Offline



Posts: 7
Joined: Oct 13th, 2009
Microsoft Outlook 2007 Calendar importing
Oct 13th, 2009 at 2:07pm
Print Post  
Hello,

I've been using the Outlook importing class 'MindFusion.Scheduling.Outlook.OutlookImporter' to bring in entries from the Microsoft Outlook Calendar, which works find for myself, but does pose a problem when there are shared Calendars involved.

The constructor of OutlookImporter does have an overload which allows you to pass both an Exchange profile & password, but these do not appear to have any effect on what entries get pulled in.

What happens is that no matter what profile I provide or password, it will always pull in (repeatatively if called more than once), the entries from my own Calendar.  Another problem is that if the 'ImportItems' method is called more than once before clearing the Calendar's Scheduled list down first, I get an identical key exception error.

Is there any update which fixes this problem?  I'm using the v5 Trial version at the moment, but could really do with having a solution to this before we commit to purchasing a full development license.

Your help is much appreciated.  Thanks.
  
Back to top
WWW  
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Microsoft Outlook 2007 Calendar importing
Reply #1 - Oct 13th, 2009 at 2:48pm
Print Post  
Hello,

The OutlookImporter always imports the items from the default calendar folder regardless of the specified authorization details. We can try modifying the importer to enable importing from different calendar folders if that is what you are trying to do.

As for the duplicated Ids, you can handle the ItemImporting event of the OutlookImporter and check whether an item with the same Id already exists in the calendar. The following code illustrates how you can do this:

Code
Select All
if (calendar.Schedule.Items.Contains(e.Item.Id))
      e.Item.Id = Guid.NewGuid().ToString(); 


You could also disallow the import of the duplicating item by setting e.Confirm to false.

Regards,
Meppy
  
Back to top
 
IP Logged
 
APEXnow
YaBB Newbies
*
Offline



Posts: 7
Joined: Oct 13th, 2009
Re: Microsoft Outlook 2007 Calendar importing
Reply #2 - Oct 13th, 2009 at 4:28pm
Print Post  
Meppy,

Many thanks for the reply. The latter solution is great for resolving the duplicate key problem, thanks.

With respect to the shared calendar importing process, this is something that we need to be able to do. The basis for this is that when scheduling different engineers to jobs, it is important for an operator to have an overall view of everyone's calendar that is shared across exchange. If there is a way for us to pull in entries for syncronization with shared Calendars, we will definately want to use Planner.NET as part of our product. Do you believe that this is something which could be done so we may formailise a license purchase?

Kind regards.

  
Back to top
WWW  
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Microsoft Outlook 2007 Calendar importing
Reply #3 - Oct 14th, 2009 at 7:18am
Print Post  
Hi,

You can download an updated version of the control from here:

https://mindfusion.eu/_pln_trial/MindFusion.Scheduling5.0c.zip

The OutlookImporter class now provides an overloaded ImportItems method, which accepts as an argument the name of the folder from which to import. Using the ImportItems overload with no arguments will still import the items from the default Calendar folder.

Let me know if this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
APEXnow
YaBB Newbies
*
Offline



Posts: 7
Joined: Oct 13th, 2009
Re: Microsoft Outlook 2007 Calendar importing
Reply #4 - Oct 14th, 2009 at 7:47am
Print Post  
Meppy,

I'll download the new update and try it out.  I'm extremely impressed by the support provided so far, your help is much appreciated.

Kind regards,
  
Back to top
WWW  
IP Logged
 
APEXnow
YaBB Newbies
*
Offline



Posts: 7
Joined: Oct 13th, 2009
Re: Microsoft Outlook 2007 Calendar importing
Reply #5 - Oct 14th, 2009 at 9:40am
Print Post  
Meppy,

I've applied the new changes, but I may be doing it incorrectly. Presently, I'm passing the name of the Shared Calendar by name, i.e. in Outlook, I have two shared Calendars plus my own. When I pass the name of the individual into ImportItems, no entries are returned. Even from my own, no entries are returned. It does return of course if I do not provide any argument.

Does the argument folder name have to be in a specific format?

[EDIT4]  Nope, Meppy, sorry, no matter what I try, it will only pull in the entries from my local Calendar, and appears to ignore all shared calendars.  Any ideas?

[EDIT3] I may have found my problem here. Leave it with me while I modify again.

[EDIT1] Meppy, I've found that although passing "Calendar" works for me alone, I've no way to distinguish between the shared Calendars. I've also even tried "\\Mailbox - <Recipient Name>\Calendar" but this doesn't work. Hope this helps to identify the problem.

[EDIT2] Further investigation shows that when I do pass "Calendar", it's pulling all of the appointments from the 'Calendar in Archive Folders' folder. Which are legacy appointments rather than the current ones from 'Calendar'.

Regards
« Last Edit: Oct 14th, 2009 at 11:01am by APEXnow »  
Back to top
WWW  
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Microsoft Outlook 2007 Calendar importing
Reply #6 - Oct 14th, 2009 at 11:19am
Print Post  
Hello again,

I am not particularly sure what does the term 'Shared Calendar' mean. Initially I though this is simply another subfolder in the Calendar navigation tab (such as those created when you right-click and select 'New Folder' from the context menu). Is it possible for you to supply me with a sample shared calendar (or tell me how to create one) and let me know how to use it within Outlook, so that I can see how these can be accessed through the automation API?

Regards,
Meppy

P.S.: What I am currently doing is enumerating all folders within Outlook and comparing the folder names to the specified argument. Once the folder is found, I am importing all items found within it.
  
Back to top
 
IP Logged
 
APEXnow
YaBB Newbies
*
Offline



Posts: 7
Joined: Oct 13th, 2009
Re: Microsoft Outlook 2007 Calendar importing
Reply #7 - Oct 14th, 2009 at 11:43am
Print Post  
Hi Meppy,

Currently, each of our Microsoft Outlook clients connect up to a Microsoft Exchange server where all emails and calendars are held. If I'm wanting to share my calendar with other Outlook users, I click on the Calendar button, and select the 'Share my Calendar' link which generates an email. I can then choose which recipients from the business address book to share the Calendar to. The same applies to other users who wish to share their Calendar to me. On the provided screen shot, I've been given access to two other people's Calendar which is shown on the left above the links panel.

How these folders are accessed from the API, I'm not entirely sure, but if it helps to narrow it down, I've got a small piece of code that was initially used some time ago before we opted for the Planner.NET method. (It's faster)

Here's the screen shot:

http://www.apexnow.co.uk/outlook.png

With respect to the code, I've listed a small snippet of the initial function we used to establish a link to the Outlook API and retrieve folders based on the provided user name: (Visual Basic.NET)

Code
Select All
	  Public Function SaveToOutlookCalendar(ByVal Name As String, ByVal StartTime As DateTime, ByVal EndTime As DateTime, ByVal Subject As String, ByVal Body As String, ByVal Location As String, ByVal Categories As String) As String
		Dim Duration As TimeSpan = EndTime.Subtract(StartTime)

		' Start Outlook.
		' If it is already running, you'll use the same instance...

		Dim OutlookRef As String = String.Empty
		Dim olApp As Microsoft.Office.Interop.Outlook.Application
		Dim olNs As Microsoft.Office.Interop.Outlook.NameSpace
		Dim oRec As Microsoft.Office.Interop.Outlook.Recipient
		Dim Calend As Microsoft.Office.Interop.Outlook.MAPIFolder
		Dim olAppt As Microsoft.Office.Interop.Outlook.AppointmentItem = Nothing

		'Dim objSafeItem As Redemption.SafeAppointmentItem

		Try
		    'olApp = CreateObject("Outlook.Application") ' !!Obsolete

		    olApp = New Microsoft.Office.Interop.Outlook.Application
		    olNs = olApp.GetNamespace("MAPI")

		    oRec = olNs.CreateRecipient(Name)
		    Calend = olNs.GetSharedDefaultFolder(oRec, OlDefaultFolders.olFolderCalendar)
		    oRec.Resolve()
		    If oRec.Resolved Then
			  ' Create a new appointment.
			  olAppt = Calend.Items.Add()
			  With olAppt
				.Start = StartTime
				.End = EndTime
				.Duration = Convert.ToUInt32(Duration.TotalMinutes)
				.Subject = Subject
				.Body = Body
				.Location = Location
				.Categories = Categories
				.ReminderMinutesBeforeStart = Nothing
				.ReminderSet = False
				.Save()
			  End With
		    End If

		    If Not olAppt Is Nothing Then
			  OutlookRef = Convert.ToString(olAppt.EntryID)
		    Else
			  OutlookRef = String.Empty
		    End If
		Catch ex As System.Exception
		    MsgBox("SAM failed to ammend the Microsoft Outlook Schedule due to the following reason: " & ex.Message)
		End Try

		Calend = Nothing
		olAppt = Nothing
		oRec = Nothing
		olApp = Nothing
		olNs = Nothing

		Return OutlookRef
	  End Function
 



Kind regards,
  
Back to top
WWW  
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Microsoft Outlook 2007 Calendar importing
Reply #8 - Oct 14th, 2009 at 12:25pm
Print Post  
Hello again,

I have prepared a new version of the control, which can be obtained from here:

https://mindfusion.eu/_pln_trial/MindFusion.Scheduling5.0e.zip

The OutlookImporter class now provides a new overload, which accepts a recipient. Use the same string you used as a recipient name in your legacy code, then invoke the ImportItems overload without arguments. This should look into the recipient's calendar.

Unfortunately, I was not able to test the new functionality because I am lacking shared calendars. Please, try it and let me know if we have any improvements.

Regards,
Meppy
  
Back to top
 
IP Logged
 
APEXnow
YaBB Newbies
*
Offline



Posts: 7
Joined: Oct 13th, 2009
Re: Microsoft Outlook 2007 Calendar importing
Reply #9 - Oct 14th, 2009 at 12:43pm
Print Post  
Hi Meppy,

Ok, I'll give it a try and see where we end up.  I sincerely appreciate the time you have spent investigating this, many thanks.

Kind regards
  
Back to top
WWW  
IP Logged
 
APEXnow
YaBB Newbies
*
Offline



Posts: 7
Joined: Oct 13th, 2009
Re: Microsoft Outlook 2007 Calendar importing
Reply #10 - Oct 14th, 2009 at 1:13pm
Print Post  
Meppy,

That's the ticket!!!  It works perfectly now.  This is a great leap for our product.  This is now going to work for us via shared Calendars.  I'll be talking with my team manager with respect to purchasing the development license as soon as possible.

Just so you know, our company site is accessable via the web link, so you'll be able to see who we are and what we do.

Again, many thanks for your help Meppy, it's been very positive.

Kind regards
  
Back to top
WWW  
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Microsoft Outlook 2007 Calendar importing
Reply #11 - Oct 14th, 2009 at 1:30pm
Print Post  
I am glad I was able to help. Smiley

Make sure to write to support@mindfusion.eu with your ordering number so that you can receive a licensed build containing the recent changes.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint