Forum

  • If you are new to these Forums, please take a moment to register using the fields above.

Announcement

Announcement Module
Collapse
No announcement yet.

dragging tasks in outlook

Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • dragging tasks in outlook

    I do a massive amount of volunteer management in my line of work, and one of the most useful techniques in GTD for me is the @waitingfor list. I use Outlook and drag and drop my sent e-mails to the task list to create my @waitingfor tasks. Most of the time I will be waiting for responses from multiple people.

    Does anyone have a trick or tip to share on creating multiple tasks from one sent e-mail without dragging and dropping multiple times? Sounds like a small thing, but I think it will make a big difference in my system if I can work out this kink.

    Thank you!

  • #2
    Here's a very rough draft of a macro that may do what you want. This macro creates an "@waiting for" Task for each Recipient of a currently selected e-mail (in either the current Inspector or Explorer). As it stands in this rough draft, the macro:
    • Saves the Tasks to the default Tasks folder. If you save these @waiting for Tasks elsewhere, we'll have to modify the code accordingly.
    • Sets the Task Reminder for one week hence. If you want a different interval, we'll modify accordingly or set up some kind of choice for the interval.
    • Also sets the Due Date one week hence.
    To test the basic functionality of this macro, copy and paste the code below into a new Module in your Outlook Visual Basic Editor. Then select an E-Mail message and run the "AtWaitingForTasksFromEmail" macro (Alt + F. You may get a Security warning. Allow access for a minute at the security prompt, and check out the results. Report back so that we can clean up the code to suit your needs.

    Regards....Bill Kratz

    Here's the code:
    Code:
    Option Explicit
    
    Sub AtWaitingForTasksFromEmail()
      ' Comments  :
      ' Parameters:  -
      ' Modified  :
      '
      ' --------------------------------------------------
      Dim objTask As Outlook.TaskItem
      Dim objApp As Outlook.Application
      Dim objCurrentItem As Object
      Dim objRecips As Outlook.Recipients
      Dim objRecip As Outlook.Recipient
      
      Set objApp = Outlook.CreateObject("Outlook.Application")
      Set objCurrentItem = GetCurrentItem()
      
      If objCurrentItem.Class = olMail Then
        Set objRecips = objCurrentItem.Recipients
        For Each objRecip In objRecips
          Set objTask = objApp.CreateItem(olTaskItem)
          objTask.Attachments.Add objCurrentItem
          objTask.Subject = "@Waiting For " & objRecip & " Regarding " & objCurrentItem.Subject
          objTask.DueDate = Date + 7
          objTask.ReminderSet = True
          objTask.ReminderTime = DateAdd("d", 7, Now)
          objTask.Display
          objTask.Save
        Next
      Else:
        MsgBox "Oops!!! This macro only works with Mail Items."
        Exit Sub
      End If
    End Sub
    
    Function GetCurrentItem() As Object
      ' Comments  :
      ' Parameters:  -
      ' Returns   : Object -
      ' Modified  :
      '
      ' --------------------------------------------------
      Dim objApp As Application
      Dim objSel As Selection
      Dim objCurrentItem As Object
      
      Set objApp = CreateObject("Outlook.Application")
      Select Case objApp.ActiveWindow.Class
        Case olExplorer
          Set objSel = objApp.ActiveExplorer.Selection
          If objSel.Count > 0 Then
            Set objCurrentItem = objSel.item(1)
          End If
        Case olInspector
          Set objCurrentItem = objApp.ActiveInspector.CurrentItem
        Case Else
      End Select
      
      Set GetCurrentItem = objCurrentItem
      
      Set objCurrentItem = Nothing
      Set objSel = Nothing
      Set objApp = Nothing
    End Function

    Comment


    • #3
      wow

      I am absolutely blown away by the generosity of your response. The macro works GREAT. How would I change it to make the task file under my @WaitingFor category?

      THANK YOU

      Comment


      • #4
        In between these two lines
        Code:
        objTask.ReminderTime = DateAdd("d", 7, Now) 
        objTask.Display
        Add the following line
        Code:
        objTask.Categories = "@WaitingFor"
        As I mentioned in the first post, this is a rough draft, and there are a few things that should be cleaned up. Use the macro for a bit, and see if anything else should be changed or added. After we've fine tuned the functionality, we'll do the housekeeping.

        Regards.....Bill Kratz

        Comment


        • #5
          Fantastic

          I can't thank you enough. I will use the macro and let you know if additional tweaks would be useful. Thank you for lending your expertise!!

          Amanda

          Comment


          • #6
            Tweak

            Bill:

            Another tweak that would be ultra useful, but I have no idea how to do it:

            Can we put today's date (in the "11.30.04" format) at the end of the task? So it would say "Amanda Regarding Tweak 11.30.04"

            Thanks!
            Amanda

            Comment


            • #7
              Replace
              Code:
              objTask.Subject = "@Waiting For " & objRecip & " Regarding " & objCurrentItem.Subject
              With
              Code:
              objTask.Subject = "@Waiting For " & objRecip & " Regarding " & objCurrentItem.Subject & " " & Format(Now, "mm.dd.yy")
              Best Regards.....Bill Kratz

              Comment


              • #8
                AWESOME

                Bill -

                Thank you!!

                Amanda

                Comment


                • #9
                  Bill,

                  How complex a macro would be required to:

                  1. Scan my Inbox for messages sent by me, where I am not on the To: or Cc: line (i.e. a Bcc: to myself, which is how I manage delegations for the @WF list),

                  2. Create a task in the task folder with "<To Recipient(s) name(s)> - <Sent Date> - <Subject>" as the subject, category = @Waiting For, task body = message body,

                  3. Delete the original message in the inbox upon successful task creation.

                  4. Avoid the Outlook security prompt by using Redemption.

                  This would let me bcc myself on delegated tasks, while not having to manage the bcc emails directly when I receive them, since I always perform the same activity (right-click drag to tasks, insert names and date before subject, Category = @Waiting For, save and close).

                  Let me know what you think. This would be a killer app for me. I may try tweaking your code below, but I really don't understand how to properly use Redemption SafeMailItems to avoid the security prompts.

                  Thanks for listening,
                  Brian

                  Comment


                  • #10
                    Originally posted by whkratz
                    Here's a very rough draft of a macro that may do what you want.
                    Great to see you back, Bill!

                    - Todd

                    Comment


                    • #11
                      Another tweak

                      Bill:

                      Is there a way to make the macro only save tasks for people in the TO line and not the CC line?

                      Amanda

                      Comment


                      • #12
                        OK, Bill's code really inspired me to work on this. Below is my revision to his original code. This code will bypass the Outlook security prompts if you have downloaded and installed Redemption. It will take the currently selected message and create a Waiting For task for each person in the To line only, formatted as "Name - Date Sent - Subject", category as "@Waiting For", email body in Task notes.

                        Code:
                        Option Explicit
                        
                        Sub AtWaitingForTasksFromEmail()
                          ' Comments  :
                          ' Parameters:  -
                          ' Modified  : 12/06/2004 - B.Davidson
                          '
                          ' --------------------------------------------------
                          Dim objTask As Outlook.TaskItem
                          Dim objApp As Outlook.Application
                          Dim objCurrentItem As Object       'currently selected item in Outlook
                          Dim objRecips As SafeRecipients    'All recipients on message
                          Dim objRecip As SafeRecipient      'Current recipient
                          Dim objWFMail                      'for Redemption mail item
                          Dim objForward                     'for Redemption mail item for getting mail body with headers
                          
                          
                          Set objApp = Outlook.CreateObject("Outlook.Application")
                          Set objCurrentItem = GetCurrentItem() 'get currently selected item
                          
                          Set objWFMail = CreateObject("Redemption.SafeMailItem") 'use Redemption to bypass the security prompts
                          objWFMail.Item = objCurrentItem  'use Redemption to bypass the security prompts
                          
                          If objWFMail.Class = olMail Then 'only run if the current item is a mail message
                            
                            Set objRecips = objWFMail.Recipients 'get all the recipients on the message (To, CC)
                            
                            For Each objRecip In objRecips 'check all the recipients
                              
                              If objRecip.Type = olTo Then 'if the current recipient is on the To line, create a @WF task
                              
                                Set objTask = objApp.CreateItem(olTaskItem) 'create a blank task
                                
                                'Set the subject per the DA white paper format (Name, Date, Subject
                                objTask.Subject = objRecip.Name & " - " & Format(objWFMail.SentOn, "mm/dd/yyyy") & " - " & objWFMail.Subject
                                
                                'Create a forwarded copy of the message to preserve the headers in the @WF task
                                Set objForward = CreateObject("Redemption.SafeMailItem")
                                objForward.Item = objCurrentItem.Forward
                                objForward.Save 'save the draft forward message so redemption can see it
                                
                                objTask.Body = objForward.Body '
                                
                                objForward.Delete 'delete the draft message (no longer needed)
                                
                                objTask.Categories = "@Waiting For"  'Change to whatever category you like
                                objTask.Save 'save your work!
                              
                              End If 'objRecip.Type = olTo
                            
                            Next 'go process the next recipient
                          Else:
                            MsgBox "Oops!!! This macro only works with Mail Items."
                            Exit Sub
                          End If
                          
                          'Variable cleanup
                          Set objTask = Nothing
                          Set objForward = Nothing
                          Set objRecip = Nothing
                          Set objRecips = Nothing
                          Set objWFMail = Nothing
                          Set objCurrentItem = Nothing
                          Set objApp = Nothing
                        
                        End Sub
                        
                        Function GetCurrentItem() As Object
                          ' Comments  :
                          ' Parameters:  -
                          ' Returns   : Object -
                          ' Modified  :
                          '
                          ' --------------------------------------------------
                          Dim objApp As Application
                          Dim objSel As Selection
                          Dim objCurrentItem As Object
                          
                          Set objApp = CreateObject("Outlook.Application")
                          Select Case objApp.ActiveWindow.Class
                            Case olExplorer
                              Set objSel = objApp.ActiveExplorer.Selection
                              If objSel.Count > 0 Then
                                Set objCurrentItem = objSel.Item(1)
                              End If
                            Case olInspector
                              Set objCurrentItem = objApp.ActiveInspector.CurrentItem
                            Case Else
                          End Select
                          
                          Set GetCurrentItem = objCurrentItem
                          
                          Set objCurrentItem = Nothing
                          Set objSel = Nothing
                          Set objApp = Nothing
                        End Function
                        I've also created a version that can be used in conjunction with an Outlook rule (with "Run a script" as the rule's action). My rule checks messages as they arrive, and if I'm not in the To: line (I've either CCed or BCCed myself), run the script "WaitingForFromEmail" and delete the message.

                        Code:
                        Public Sub WaitingForFromEmail(MyMail As Outlook.MailItem)
                          ' Comments  :
                          ' Parameters:  -
                          ' Modified  : 12/06/2004 - B.Davidson
                          '
                          ' --------------------------------------------------
                          Dim objTask As Outlook.TaskItem
                          Dim objApp As Outlook.Application
                          Dim objRecips As SafeRecipients    'All recipients on message
                          Dim objRecip As SafeRecipient      'Current recipient
                          Dim objWFMail                      'for Redemption mail item
                          Dim objForward                     'for Redemption mail item for getting mail body with headers
                          
                          
                          Set objApp = Outlook.CreateObject("Outlook.Application")
                          
                          Set objWFMail = CreateObject("Redemption.SafeMailItem") 'use Redemption to bypass the security prompts
                          objWFMail.Item = MyMail 'use Redemption to bypass the security prompts
                          
                          If objWFMail.Class = olMail Then 'only run if the current item is a mail message
                            
                            Set objRecips = objWFMail.Recipients 'get all the recipients on the message (To, CC)
                            
                            For Each objRecip In objRecips 'check all the recipients
                              
                              If objRecip.Type = olTo Then 'if the current recipient is on the To line, create a @WF task
                              
                                Set objTask = objApp.CreateItem(olTaskItem) 'create a blank task
                                
                                'Set the subject per the DA white paper format (Name, Date, Subject
                                objTask.Subject = objRecip.Name & " - " & Format(objWFMail.SentOn, "mm/dd/yyyy") & " - " & objWFMail.Subject
                                
                                'Create a forwarded copy of the message to preserve the headers in the @WF task
                                Set objForward = CreateObject("Redemption.SafeMailItem")
                                objForward.Item = MyMail.Forward
                                objForward.Save 'save the draft forward message so redemption can see it
                                
                                objTask.Body = objForward.Body 'copy the email body with basic headers to task note field
                                
                                objForward.Delete 'delete the draft message (no longer needed)
                                
                                objTask.Categories = "@Waiting For"  'Change to whatever category you like
                                objTask.Save 'save your work!
                              
                              End If 'objRecip.Type = olTo
                            
                            Next 'go process the next recipient
                          Else:
                            
                            Exit Sub
                          End If
                          
                          'Variable cleanup
                          Set objTask = Nothing
                          Set objForward = Nothing
                          Set objRecip = Nothing
                          Set objRecips = Nothing
                          Set objWFMail = Nothing
                          Set objApp = Nothing
                          
                        End Sub
                        I don't know how clean or efficient this code is, but it does what I want without the instability of the GTD Add-in and extra overhead.

                        I welcome any further ideas or inputs with anyone else playing with these types of macros.

                        Brian

                        Comment


                        • #13
                          Nice job Brian!

                          Amanda, I'm sure that you can see how Brian's "If objRecip.Type = olTo Then ... code answers your question regarding the "To recipients" versus the "CC recipients".

                          We should still clean up both versions of the macro (disassociating variables, tightening up variable declarations, error handling...), so after both of you (and hopefully some others) play around with it for a bit, report back and then we'll do some housekeeping.

                          Best Regards.....Bill Kratz

                          Comment


                          • #14
                            hmmmm

                            When I add in the line
                            If objRecip.Type = olTo Then

                            I am getting an error that I have a Next without a For ?? - It seems to be referring to the next at the end of the script.

                            Am I not adding enough in? Perhaps I should start over?

                            Thanks guys.

                            Comment


                            • #15
                              Re: hmmmm

                              Originally posted by ameasha
                              When I add in the line
                              If objRecip.Type = olTo Then

                              I am getting an error that I have a Next without a For ?? - It seems to be referring to the next at the end of the script.

                              Am I not adding enough in? Perhaps I should start over?

                              Thanks guys.
                              Don't forget the

                              Code:
                              End If
                              before the Next to close out the If statement.

                              Brian

                              Comment

                              Working...
                              X