Send an Email to GoodTodo

Here’s your Daily Dose of Outlook. There are a few things I don’t like about forwarding messages to GoodTodo. I don’t like the FW in the title indicating it was forwarded. I don’t like that I have to delete my signature from the newly created message. I don’t like that I have to create space at the top of the message to record my Next Action. And I don’t like confidentiality disclaimers ad infinitum. When I don’t like something, I code to make it better.

Public Sub SendToToday()
   
    Dim miItem As MailItem
    Dim miNew As MailItem
   
    On Error Resume Next
        Select Case TypeName(Application.ActiveWindow)
            Case “Explorer”
                Set miItem = ActiveExplorer.Selection.Item(1)
            Case “Inspector”
                Set miItem = ActiveInspector.CurrentItem
            Case Else
        End Select
    On Error GoTo 0
   
    Set miNew = Application.CreateItem(olMailItem)
   
    miNew.To = “today@goodtodo.com”
    miNew.Subject = miItem.ConversationTopic
    miNew.Body = “NA: “ & String(5, vbNewLine) & miItem.Body
    miNew.Display
    SendKeys “{END}”
   
    miItem.Close olDiscard
   
End Sub

This takes the current email, whether open or just selected, and creates a new email. The new email is sent to today@goodtodo.com which is where I send 95% of GoodTodo forwards. The ConversationTopic is brought from the current message to the new message’s Subject, which serves to strip out and FWs or REs and make a nice, clean GoodTodo task subject. Then, the body is brought over but NA: and five blank lines are put there first. After I display the message, I use the dreaded SendKeys to put my cursor at the end of the NA line so I can start typing my next action.

Oh, how I dislike SendKeys. Outlook doesn’t offer a lot in the way of selecting text. Originally, I wanted to open the original message, select the text to be included in the todo and press a button. But I couldn’t figure a way through Outlook’s object model to get the selected text. If I use Word as my email editor I could probably do it. But that’s about as appealing as tying a freight train to my belt. Maybe I could use the clipboard. Hang on a sec…

OK, new code coming. The clipboard things works nicely. I select and copy the portion of the email I want, then run this code

Public Sub SendToToday2()
   
    Dim clip As DataObject
    Dim sBody As String
    Dim miNew As MailItem
    Dim miItem As MailItem
   
    Set clip = New DataObject
    clip.GetFromClipboard
   
    Set miNew = Application.CreateItem(olMailItem)
    Set miItem = Application.ActiveInspector.CurrentItem
   
    sBody = “NA: “ & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine
    sBody = sBody & “>” & miItem.SenderEmailAddress & ” “ & miItem.SentOn & vbNewLine
    sBody = sBody & clip.GetText
       
    With miNew
        .To = “today@goodtodo.com”
        .Subject = miItem.ConversationTopic
        .Body = sBody
        .Display
    End With
   
    SendKeys “{END}”
   
    miItem.Close olDiscard
       
End Sub

This creates a new email with only the portion I copied from the original and adds the sender’s name and went it was sent. This email:

becomes this email

becomes this todo

I’ve really got to figure how to send email through gmail so I can dump Outlook altogether. Someday. Maybe I’ll put it on my todo list.

Posted in Uncategorized

6 thoughts on “Send an Email to GoodTodo

  1. Is there a way to include the copy command in the macro? So highlight some text, and have that text available in VBA to perform some operation with it?

  2. TV: Great minds think alike. I did that after I forgot to copy the first few times with

    SendKeys “^C”

    . I was going to post about it today, but now it doesn’t work (it worked yesterday the few times I tried it). It executes the line, even in break mode, but it just won’t copy to the clipboard no matter what. Such is SendKeys. I’d love to the get the copy command in there somehow though.

  3. Attachments! How could I forget about attachments? Also, if the clipboard contains something that isn’t text, an error occurs. That’s easy enough to fix, but I’m becoming less enamored with this code. Time to rethink.

  4. I tried SendKeys “^c” as well, but was confused by the result. The first time it didn’t seem to do anything, it kept whatever was on the clipboard already. If I then run it a second time the clipboard contains that same text surrounded by some additional text:

    ——————
    Microsoft Office Outlook
    ——————
    Original Clipboard Content
    ——————
    OK
    ——————

    Each subsequent running of it takes the above and continues to append that to the top and bottom. Strange..

  5. Not to nitpick but you should be adding recipients using the Recipients collection, i.e.

    Dim recip As Outlook.Recipient
    Set recip = miNew.Recipients.Add(“today@goodtodo.com”)
    recip.Type = olTo

Leave a Reply

Your email address will not be published. Required fields are marked *