Category: Blog

Your blog category

  • VB.NET – Windows – Outlook

    Here’s my code for marking a set of Tasks complete, based on the subject, and for creating a new Task:

     

    The part that bugs me the most, is the oNS.Login.  I have to put in my exchange profile and my password and yet, Outlook still asks for my password.  This is why I think that the application should be an outlook plug in.

     

    ‘ Create an Outlook application.
    Dim oApp As outlook.Application = New outlook.Application()

     

    ‘ Get NameSpace and Logon.
    Dim oNS As outlook.NameSpace = oApp.GetNamespace("mapi")
    ‘ oNS.Logon("YourValidProfile", Missing.Value, False, True) ‘ TODO:

     

    ‘ mark any uncompleted tasks to complete
    Dim oTasks As outlook.MAPIFolder = oNS.GetDefaultFolder(outlook.OlDefaultFolders.olFolderTasks)

     

    ‘ Get the first contact from the Contacts folder.
    Dim oItems As outlook.Items = oTasks.Items
    Dim oItem As outlook.TaskItem

     

    oItems = oItems.Restrict("[Subject] = Change Infusion Set")
    Dim i As Integer
    For i = 1 To oItems.Count
    oItem = oItems.Item(i)
    If Not oItem.Complete Then oItem.MarkComplete()
    oItem.Save()
    Next

     

    ‘ Create a new AppointmentItem.
    Dim oTask As outlook.TaskItem = oApp.CreateItem(outlook.OlItemType.olTaskItem)

    ‘ Set some common properties.
    oTask.Subject = "Change Infusion Set"
    oTask.Body = "Change Infusion Set"

     

    ‘Find number of days to add to task which is the smaller of the number of days or Total Insulin divided by TDD
    Dim days As Integer = Val(txtDays.Text)
    Dim StrDate As String
    Dim insulinDays As Integer = Val(txtTotal.Text) / Val(txtTDD.Text)
    If days > insulinDays Then
    days = Int(insulinDays)
    End If
    StrDate = Convert.ToDateTime(Date.Today.AddDays(days))

     

    ‘Creating the Task

    oTask.StartDate = StrDate
    oTask.DueDate = StrDate
    oTask.Complete = False
    oTask.DateCompleted = Nothing
    oTask.Status = outlook.OlTaskStatus.olTaskNotStarted

     

    If reminder = True Then
    oTask.ReminderSet = True
    Dim StrTime As String = Convert.ToString(Me.DateTimePicker1.Value.TimeOfDay)
    oTask.ReminderTime = Convert.ToDateTime(StrDate & " " & StrTime)
    Else
    oTask.ReminderSet = False
    End If

     

    ‘ Save to Tasks
    oTask.Save()
    ‘ Logoff.
    oNS.Logoff()

     

    ‘ Clean up.
    oApp = Nothing
    oNS = Nothing
    oTask = Nothing

     

    ‘Note I’ve lost my formatting, but I think you can get the point.

  • VB.Net (2005) and using the Registry

    One of the decision I made on my program was to use the registry to store my data.  Everyone else does and we are talking 4 small values.  Using the registry with Visual Basic is not hard, just calls.

     

    Here’s how I retrieve the registry settings:

     

    Me.txtTDD.Text = GetSetting("InfusionSetHelper", "Settings", "TDD", "")
    Me.txtDays.Text = GetSetting("InfusionSetHelper", "Settings", "Days", "")
    Me.txtTotal.Text = GetSetting("InfusionSetHelper", "Settings", "Total", "")

     

    And here’s an example of setting them:

     

    SaveSetting("InfusionSetHelper", "Settings", "Days", strDays)

     

    Deleting a setting:

     

    DeleteSetting("InfusionSetHelper", "Settings", "TDD")

     

    While this works and does a nice job, the documentation at http://msdn.microsoft.com/en-us/library/cy6azwf7(VS.80).aspx says to do it another way, and that way is more compatible with Windows Mobile.  I may change this code.

  • Windows Mobile Program done

    I’ve got most of the logic complete on the Windows Mobile project and boy howdy, so far, I’ve learned a lot.  One of my goals today is to record all the things I’ve learned.

     

    However, I’ve decided to make some changes.  I really think that the Infusion Set Helper ought to be an Outlook PlugIn, since you have to log into Outlook if you have an exchange server, or at least I have to.

     

    I still want the Windows Mobile program to be a ToDay plugin, so there is still work to be done on that and learning curve.  But it IS coming along.

  • Using ID with Microsoft Objects

    Just a quick note to remind me where this article is.  I’ve been looking at http://support.microsoft.com/kb/293152/ which I think will help me mark my tasks complete.

  • Update on my project

    Didn’t get to spend much time on the project, today.  I got appointments to create on my older Gateway tablet, but couldn’t get them to work on my new Lenovo, which is where I have working on this.  The weird part is that I couldn’t Add an Reference to the Microsoft Office PIAs, but when I transferred the program to the other computer using my network, added the code to create a task, and then moved it back, the PIA reference was there. Weirdness.

     

    I’ve decided to add a "reminder time" to the project, and with a little research found I can use the DateTimePicker to get my time. 

     

    And now I’m fighting with the notebook again.  The district installed Groupwise which is getting into the way.  I am deleting the Groupwise account now, but am probably going to have to uninstall Groupwise.

  • First permutation of the project

    I’ve created a simple Windows — not Windows Mobile yet — application that shows the date of the next infusion change if the user has put in the number of days, or has put in the Total number of units and the average daily total. The application does several things I haven’t done before:

    1. Add days to the current date value — super easy — Date.Today.AddDays(intTDDDays) where the arguments is the number of days to add.
    2. Set values in the registry — again easy — SaveSetting("InfusionSetHelper", "Settings", "TDD", strTDD)
    3. Retrieve values in the registry — again easy — Me.txtTotal.Text = GetSetting("InfusionSetHelper", "Settings", "Total", "")

     

    So the next decision to be made, is do I make this a Windows program that updates outlook, so should I got straight to the Windows Mobile application.  I think having it both places might be useful.

  • Rough Design of Windows Mobile Application

    I’ve been giving this a lot of thought and at the moment, this is what I think I need:

    • It should be a Today PlugIn.
    • Store TDD (but make it optional since it is not an issue for everyone)
    • Store number of days, with a default of 3 – use a Combo box
    • Store information on the open task so it can be marked completed
    • When the user clicks on the plug give the option to chose day or use given date, or ignore.
      • When selected the current open task is marked complete (but stays so that it can be tracked or deleted manually — though this could be an option.)
      • A new task is created based on TDD and number of days, which ever results in smallest day.  However, TDD may be ignored.
  • How To Access Pocket Outlook Objects from VBCE

    Here’s the bloody details, so the research end is going well.

    How To Access Pocket Outlook Objects from VBCE

    How To Access Pocket Outlook Objects from VBCE