Outlook Macro: email tasks to RTM with dates, priority, notes

Here's the macro I used today to export 100+ tasks into RTM from Outlook 2003 (after a LOT of testing - suggest you set the email address to a personal account before you set it to your RTM inbox, just to check out what it'll do).
Recurrence is not supported directly, though your recurring tasks will send (Outlook's raw) recurrence information in a note.
What I did: I had few recurring tasks. I modified the If statement to check for (t.Complete True) AND (t.IsRecurring = True) and sent the recurring tasks to RTM first. I updated the recurrence on these tasks on RTM, then switched the line to IsRecurring = False and sent the rest.
Hope this saves someone a bunch of work (and hope it posts well to the board).
I used several other people's macros as source material and inspiration, but added a bunch of stuff along the way. HTH!
RTM: You really need to get Outlook sync working. Workarounds like this are hacky and they stink. If I can code up a macro to export in an afternoon, how hard can it be to make a sync program in 5 years?
Sub PostToRTM()
Dim f As MAPIFolder
Set f = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderTasks)
Dim t As TaskItem
Dim rtmStart As String
Dim rtmDue As String
Dim rtmNote As String
Dim rtmList As String
Dim rtmPriority As String
Dim rtmTaskItemProps As String
Dim rtmMessageBody As String
Dim rtmRecurringTask As String
Dim rtmRecurrenceInfo As String
Dim rtmRecurrenceDayOfMonth As String
Dim rtmRecurrenceDayMask As String
Dim rtmRecurrenceInterval As String
Dim rtmRecurrenceMonth As String
Dim rtmRecurrencePatternStartDate As String
Dim rtmRecurrencePatternEndDate As String
Dim rtmRecurrenceRegenerate As String
For Each t In f.Items
If (t.Complete True) Then
rtmStart = t.StartDate
rtmDue = t.DueDate
rtmNote = t.Body
rtmList = t.Categories
rtmPriority = t.Importance
rtmMessageBody = "Priority: " & rtmPriority & vbCrLf & "Due: " & rtmDue & vbCrLf & "List: " & rtmList & vbCrLf
If rtmNote "" Then
rtmMessageBody = rtmMessageBody & "---" & vbCrLf & rtmNote & vbCrLf
End If
rtmRecurringTask = t.IsRecurring
If rtmRecurringTask = True Then
rtmRecurrenceInfo = t.GetRecurrencePattern.RecurrenceType
rtmRecurrenceDayOfMonth = t.GetRecurrencePattern.DayOfMonth
rtmRecurrenceDayMask = t.GetRecurrencePattern.DayOfWeekMask
rtmRecurrenceInterval = t.GetRecurrencePattern.Interval
rtmRecurrenceMonth = t.GetRecurrencePattern.MonthOfYear
rtmRecurrencePatternStartDate = t.GetRecurrencePattern.PatternStartDate
rtmRecurrencePatternEndDate = t.GetRecurrencePattern.PatternEndDate
rtmRecurrenceRegenerate = t.GetRecurrencePattern.Regenerate
rtmMessageBody = rtmMessageBody & "---" & vbCrLf & _
"RECURRENCE INFO" & vbCrLf & _
"Recurrence Info: " & rtmRecurrenceInfo & vbCrLf & _
"Recurrence Day of Month: " & rtmRecurrenceDayOfMonth & vbCrLf & _
"Recurrence Day Mask: " & rtmRecurrenceDayMask & vbCrLf & _
"Recurrence Interval: " & rtmRecurrenceInterval & vbCrLf & _
"Recurrence Month:" & rtmRecurrenceMonth & vbCrLf & _
"Recurrence Pattern Start Date: " & rtmRecurrencePatternStartDate & vbCrLf & _
"Recurrence Pattern End Date: " & rtmRecurrencePatternEndDate & vbCrLf & _
"Recurrence Regenerate: " & remRecurrenceRegenerate & vbCrLf
End If
rtmMessageBody = rtmMessageBody & "-end-" & vbCrLf
Dim mail As MailItem
Set mail = Application.CreateItem(olMailItem)
mail.To = "***************Your RTM Email Address Here *********************"
mail.Subject = t.Subject
mail.BodyFormat = olFormatPlain
mail.Body = rtmMessageBody
mail.DeleteAfterSubmit = True
mail.Send
End If
Next
End Sub
Recurrence is not supported directly, though your recurring tasks will send (Outlook's raw) recurrence information in a note.
What I did: I had few recurring tasks. I modified the If statement to check for (t.Complete True) AND (t.IsRecurring = True) and sent the recurring tasks to RTM first. I updated the recurrence on these tasks on RTM, then switched the line to IsRecurring = False and sent the rest.
Hope this saves someone a bunch of work (and hope it posts well to the board).
I used several other people's macros as source material and inspiration, but added a bunch of stuff along the way. HTH!
RTM: You really need to get Outlook sync working. Workarounds like this are hacky and they stink. If I can code up a macro to export in an afternoon, how hard can it be to make a sync program in 5 years?
Sub PostToRTM()
Dim f As MAPIFolder
Set f = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderTasks)
Dim t As TaskItem
Dim rtmStart As String
Dim rtmDue As String
Dim rtmNote As String
Dim rtmList As String
Dim rtmPriority As String
Dim rtmTaskItemProps As String
Dim rtmMessageBody As String
Dim rtmRecurringTask As String
Dim rtmRecurrenceInfo As String
Dim rtmRecurrenceDayOfMonth As String
Dim rtmRecurrenceDayMask As String
Dim rtmRecurrenceInterval As String
Dim rtmRecurrenceMonth As String
Dim rtmRecurrencePatternStartDate As String
Dim rtmRecurrencePatternEndDate As String
Dim rtmRecurrenceRegenerate As String
For Each t In f.Items
If (t.Complete True) Then
rtmStart = t.StartDate
rtmDue = t.DueDate
rtmNote = t.Body
rtmList = t.Categories
rtmPriority = t.Importance
rtmMessageBody = "Priority: " & rtmPriority & vbCrLf & "Due: " & rtmDue & vbCrLf & "List: " & rtmList & vbCrLf
If rtmNote "" Then
rtmMessageBody = rtmMessageBody & "---" & vbCrLf & rtmNote & vbCrLf
End If
rtmRecurringTask = t.IsRecurring
If rtmRecurringTask = True Then
rtmRecurrenceInfo = t.GetRecurrencePattern.RecurrenceType
rtmRecurrenceDayOfMonth = t.GetRecurrencePattern.DayOfMonth
rtmRecurrenceDayMask = t.GetRecurrencePattern.DayOfWeekMask
rtmRecurrenceInterval = t.GetRecurrencePattern.Interval
rtmRecurrenceMonth = t.GetRecurrencePattern.MonthOfYear
rtmRecurrencePatternStartDate = t.GetRecurrencePattern.PatternStartDate
rtmRecurrencePatternEndDate = t.GetRecurrencePattern.PatternEndDate
rtmRecurrenceRegenerate = t.GetRecurrencePattern.Regenerate
rtmMessageBody = rtmMessageBody & "---" & vbCrLf & _
"RECURRENCE INFO" & vbCrLf & _
"Recurrence Info: " & rtmRecurrenceInfo & vbCrLf & _
"Recurrence Day of Month: " & rtmRecurrenceDayOfMonth & vbCrLf & _
"Recurrence Day Mask: " & rtmRecurrenceDayMask & vbCrLf & _
"Recurrence Interval: " & rtmRecurrenceInterval & vbCrLf & _
"Recurrence Month:" & rtmRecurrenceMonth & vbCrLf & _
"Recurrence Pattern Start Date: " & rtmRecurrencePatternStartDate & vbCrLf & _
"Recurrence Pattern End Date: " & rtmRecurrencePatternEndDate & vbCrLf & _
"Recurrence Regenerate: " & remRecurrenceRegenerate & vbCrLf
End If
rtmMessageBody = rtmMessageBody & "-end-" & vbCrLf
Dim mail As MailItem
Set mail = Application.CreateItem(olMailItem)
mail.To = "***************Your RTM Email Address Here *********************"
mail.Subject = t.Subject
mail.BodyFormat = olFormatPlain
mail.Body = rtmMessageBody
mail.DeleteAfterSubmit = True
mail.Send
End If
Next
End Sub


gogogadgetscott says:
Thank you for sharing!!!

davidpodhola says:
Actually there is already a sync done: https://www.rememberthemilk.com/forums/tips/10051/

tinarenee says:
yes, david - but not for Outlook 2003, as is what jimmie is using...(and me.)