Twittering from Outlook Using VBA



Recently I toyed with the idea of letting my boss know what tasks I completed in a day in the hope he actually believes I’m doing something.  I thought of sending constant emails or keeping a diary.    Something briefer was would be more useful.

This got me thinking about services such as Twitter.  Perhaps it has a purpose after all.

I do keep track of tasks in Outlook using the “Getting Things Done” method (I’ll post on this another time) using macros.  I thought I’d see how easy it was to report status updates to twitter.  As it turns out, very easy!

The following simple code sample can be reused to send messages to Twitter:

Sub PromptForTwitterPost()
    Dim lsInput As String
    lsInput = InputBox("Type in text of twitter Post", "Twitter", "")
    If lsInput = "" Then Exit Sub
    PostToTwitter lsInput
End Sub
Sub PostToTwitter(statusUpdate As String)
    PostToTwitterWithAuth statusUpdate, "someuserid", "somepassword"
End Sub
Sub PostToTwitterWithAuth(statusUpdate As String, username As String, password As String)

     Dim WinHttpReq As New WinHttpRequest
     ' Assemble an HTTP Request.
    WinHttpReq.Open "POST", _
      "" & statusUpdate, False
    WinHttpReq.SetCredentials "yyyyyyyyy", "xxxxxxxxx", HTTPREQUEST_SETCREDENTIALS_FOR_SERVER
    ' Send the HTTP Request.
End Sub


This example will work with any Office VBA or VB6 language. 

You can use this macro to use task items to get the status text:


Sub ReportTaskAsComplete()

   ' Extract task title
   For Each loItem In Outlook.Application.ActiveExplorer.Selection
    If TypeOf loItem Is TaskItem Then
         Dim loTask As TaskItem
         Set loTask = loItem
         loTask.Status = olTaskComplete
         PostToTwitter Task.Subject & " - Complete"
    End If

End Sub



  • If you want a deluxe solution for Twittering in Outlook, try Outwit

5 responses »

  1. Pingback: Twittering using the Compact Framework « An Original Idea

  2. Question…

    In the following what is “yyyyyyyyy” & “xxxxxxxxx” (ie, which one if pass & which userid)?

    WinHttpReq.Open “POST”, _
    “” & statusUpdate, False
    WinHttpReq.SetCredentials “yyyyyyyyy”, “xxxxxxxxx”, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER

  3. Pingback: Updating Twitter via SuperTweet using VBA « An Original Idea

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s