<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,7 +1,7 @@
 VERSION 5.00
 Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} TodoForm 
    Caption         =   &quot;Tracks Todo&quot;
-   ClientHeight    =   3855
+   ClientHeight    =   4725
    ClientLeft      =   45
    ClientTop       =   330
    ClientWidth     =   7035
@@ -14,6 +14,7 @@ Attribute VB_Creatable = False
 Attribute VB_PredeclaredId = True
 Attribute VB_Exposed = False
 
+
 Option Explicit
 
 ' greg jarman   20080821   v1.0     initial version
@@ -22,7 +23,7 @@ Option Explicit
 
 ' the URL of the tracks installation, required.
 Const sURL = &quot;http://your.tracks.host/tracks/&quot;
-
+ 
 ' set username and password here, required.
 Const sUsername = &quot;userid&quot;
 Const sPassword = &quot;password&quot;
@@ -32,7 +33,7 @@ Const sProxy = &quot;&quot;
 
 ' set this to true if you want to refresh the projects and contexts each time a new todo is created.
 ' otherwise the data is gathered the first time a todo is created after outlook is opened.
-Const Update_Projects_And_Contexts_Each_Time = False
+Const Update_Projects_And_Contexts_Each_Time = True
 
 ' internal variables
 Private Type Context
@@ -49,6 +50,7 @@ Private Type Project
 End Type
 
 Dim Projects() As Project
+Dim ActiveProjects() As Project
 Dim Projects_Length As Integer
 Public Projects_Loaded As Boolean
 
@@ -69,6 +71,7 @@ End Function
 
 Private Sub ConfigureWinHttpRequest(WinHttpRequest As Variant)
   WinHttpRequest.SetCredentials sUsername, sPassword, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER
+  WinHttpRequest.SetRequestHeader &quot;Content-type&quot;, &quot;text/xml&quot;
   If Len(sProxy) &gt; 0 Then
     WinHttpRequest.SetProxy 2, sProxy, &quot;&quot;
   End If
@@ -189,11 +192,18 @@ Private Sub PopulateProjectListBox()
   TodoForm.ProjectListBox.Style = fmStyleDropDownList
     
   Dim i
+  Dim count As Integer
+  ReDim ActiveProjects(0 To Projects_Length - 1)
+  count = 0
+  
   For i = 0 To Projects_Length - 1
     If Projects(i).State = &quot;active&quot; Then
       TodoForm.ProjectListBox.AddItem Projects(i).Name
+      ActiveProjects(count) = Projects(i)
+      count = count + 1
     End If
   Next i
+  
   TodoForm.ProjectListBox.ListIndex = old_index
 End Sub
 
@@ -246,7 +256,7 @@ Private Function HTMLEncode(ByVal Text As String, Optional HardSpaces As Boolean
   HTMLEncode = NewString
 End Function
 
-Private Sub CreateTodo(Description As String, Notes As String, ContextID As Integer, ProjectID As Integer)
+Private Sub CreateTodo(Description As String, Notes As String, ContextId As Integer, ProjectId As Integer)
   Dim WinHttpRequest As Object
   Dim sData As String
   Dim aBody() As Byte
@@ -255,15 +265,15 @@ Private Sub CreateTodo(Description As String, Notes As String, ContextID As Inte
   WinHttpRequest.Open &quot;POST&quot;, sURL &amp; &quot;todos.xml&quot;, False
   ConfigureWinHttpRequest WinHttpRequest
     
-  sData = &quot;todo[description]=&quot; &amp; HTMLEncode(Description) &amp; _
-    &quot;&amp;todo[notes]=&quot; &amp; HTMLEncode(Notes) &amp; _
-    &quot;&amp;todo[context_id]=&quot; &amp; HTMLEncode(Str(ContextID))
+  sData = &quot;&lt;todo&gt;&lt;description&gt;&quot; + Description + &quot;&lt;/description&gt;&quot;
+  sData = sData &amp; &quot;&lt;notes&gt;&quot; &amp; Notes &amp; &quot;&lt;/notes&gt;&quot;
+  sData = sData &amp; &quot;&lt;context_id&gt;&quot; &amp; Str(ContextId) &amp; &quot;&lt;/context_id&gt;&quot;
     
-  If ProjectID &gt; 0 Then
-    sData = sData &amp; &quot;&amp;todo[project_id]=&quot; &amp; HTMLEncode(Str(ProjectID))
+  If ProjectId &gt; 0 Then
+    sData = sData &amp; &quot;&lt;project_id&gt;&quot; &amp; Str(ProjectId) &amp; &quot;&lt;/project_id&gt;&quot;
   End If
 
-  sData = sData &amp; vbCrLf
+  sData = sData &amp; &quot;&lt;/todo&gt;&quot; &amp; vbCrLf
     
   aBody = StrConv(sData, vbFromUnicode)
   WinHttpRequest.Send CByte(aBody)
@@ -281,7 +291,15 @@ Private Sub AddActionButton_Click()
   ElseIf ContextListBox.ListIndex = -1 Then
     MsgBox &quot;Must have a context!&quot;, vbExclamation
   Else
-    CreateTodo DescriptionTextBox.Text, NotesTextBox.Text, ContextListBox.ListIndex + 1, ProjectListBox.ListIndex + 1
+    Dim ContextId As Integer
+    Dim ProjectId As Integer
+    ContextId = Contexts(ContextListBox.ListIndex).id
+    ProjectId = 0
+    If ProjectListBox.ListIndex &gt; 0 Then
+      ProjectId = ActiveProjects(ProjectListBox.ListIndex).id
+    End If
+    
+    CreateTodo DescriptionTextBox.Text, NotesTextBox.Text, ContextId, ProjectId
     FormReset
     TodoForm.Hide
   End If
@@ -297,6 +315,11 @@ Private Sub CancelButton_Click()
   TodoForm.Hide
 End Sub
 
+
+Private Sub ClearProject_Click()
+  ProjectListBox.ListIndex = -1
+End Sub
+
 Private Sub UserForm_Initialize()
   Contexts_Loaded = False
   Projects_Loaded = False</diff>
      <filename>TodoForm10.frm</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>TodoForm10.frx</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>cd6f6d45750e20f4961f2eaf78c027bc269b8fd9</id>
    </parent>
  </parents>
  <author>
    <name>Reinier Balt</name>
    <email>lrbalt@gmail.com</email>
  </author>
  <url>http://github.com/lrbalt/outlookemailtotracks/commit/39bd888b9f31a44ac8be94bd3a7263d5dd8b4371</url>
  <id>39bd888b9f31a44ac8be94bd3a7263d5dd8b4371</id>
  <committed-date>2009-02-04T12:58:04-08:00</committed-date>
  <authored-date>2009-02-04T12:58:04-08:00</authored-date>
  <message>update code to work with recent version of tracks</message>
  <tree>6851399c9145c4dcd9a3f763fbd050f523bddd6b</tree>
  <committer>
    <name>Reinier Balt</name>
    <email>lrbalt@gmail.com</email>
  </committer>
</commit>
