dragging tasks in outlook

Michael Hyatt

Registered
Can someone re-post the complete, corrected code? I would like to direct my blog readers to this great macro. (Also, Bill has anything new happened on your Web site? I'd be happy to direct people there, too.)
 

ameasha

Registered
Complete Code

Michael, here is the complete working code:

Code:
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
	    If objRecip.Type = olTo Then
	      Set objTask = objApp.CreateItem(olTaskItem)
	      objTask.Attachments.Add objCurrentItem
	      objTask.Subject = objRecip & " - " & objCurrentItem.Subject & " " & Format(Now, "mm.dd.yy")
	      objTask.ReminderSet = True
	      objTask.ReminderTime = DateAdd("d", 7, Now)
	      objTask.Categories = "@WaitingFor"
	      objTask.Display
	      objTask.Save
	    End If
	    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
 

bdavidson

Registered
Michael Hyatt said:
Can someone re-post the complete, corrected code? I would like to direct my blog readers to this great macro. (Also, Bill has anything new happened on your Web site? I'd be happy to direct people there, too.)

I have also edited my original message to include all the edits I've made to my offshoot of Bill's original code.
 

ameasha

Registered
Dear Bill or any interested Macro Wizard:

I'd love to tweak our macro code to copy the text of the e-mail into the task rather than including the e-mail as an attachment. This would allow me to read the text on my Palm when I'm out and about. Does anyone know what changes I would need to make?

Thank you!!
Amanda
 

BrianK

Registered
Haven't tested this, but try this:

Between

objTask.Categories = "@WaitingFor"

and

objTask.Display

insert:

objTask.Body = objCurrentItem.Body

So it reads:

objTask.Categories = "@WaitingFor"
objTask.Body = objCurrentItem.Body
objTask.Display

That should copy the body of the email (but not the headers) as the body of the task, I think.

And if I've totally botched Bill's code, I apologize.
 

ameasha

Registered
Brian:

Thank you! I'd like to take the attachment off altogether. Do you think removing this line would do the trick?

Code:
objTask.Attachments.Add objCurrentItem

Thanks!
Amanda
 

BrianK

Registered
ameasha said:
Brian:

Thank you! I'd like to take the attachment off altogether. Do you think removing this line would do the trick?

Code:
objTask.Attachments.Add objCurrentItem

Thanks!
Amanda

Oops. :oops:

Yeah, that should do it. Did the objCurrentItem.Body add just the body, and not the headers?
 

ameasha

Registered
Yes, but I hadn't actually noticed that until you pointed it out :oops:
Do you know how we can add the headers too?

Thank you!
Amanda
 

bdavidson

Registered
ameasha said:
Yes, but I hadn't actually noticed that until you pointed it out :oops:
Do you know how we can add the headers too?

Thank you!
Amanda

My post here does that in a roundabout manner by creating a forwarded version of the email to put the headers into the body, then copying that body into the task.

Brian
 

BrianK

Registered
Do you know how we can add the headers too?

This is a clunky effort at re-creating the header. Instead of

objTask.Body = objCurrentItem.Body

Try this monster line:

objTask.Body = "From: " & objCurrentItem.SenderName & vbCrLf & "To: " & objCurrentItem.To & vbCrLf & "CC: " & objCurrentItem.CC & vbCrLf & objCurrentItem.SentOn & vbCrLf & "----------" & vbCrLf & vbCrLf & objCurrentItem.Body

It should result in the task body looking like this:

  • From: Joe Blow
    To: Amos Smith, Andy Jones
    CC: bettysue @ fakeemail.com
    12/15/04 12:19:40 PM
    ----------

    [body of the email]

If you want to play around with other properties that you can add to it, a good list of them is here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaol11/html/olobjMailItem.asp
 

MsftMan

Registered
bdavidson said:
Michael Hyatt said:
Can someone re-post the complete, corrected code? I would like to direct my blog readers to this great macro. (Also, Bill has anything new happened on your Web site? I'd be happy to direct people there, too.)

I have also edited my original message to include all the edits I've made to my offshoot of Bill's original code.

Brian, is your code written for an Exchange server or something different? Because I see code that gives my stand alone version some problems. Mainly the difference between the original code:

Dim objRecips As Outlook.Recipients
vs. your code
Dim objRecips As SafeRecipients

Also your code halted on some "objWFMail" commands even though I have Redemption installed.

Thanks,
Steve
 

bdavidson

Registered
Steve,

It was written and tested in an Exchange environment with Outlook 2003, but I'm not keenly aware of any Exchange specific code, unless it's something to do with the way Recipents are handled in a non-Exchange account.

I installed Redemption from www.dimastr.com, even though it also appeared to be installed by the GTD Add-in as well.

Aside from this info, I'm not saavy enough in VBA to isolate the problem any further... :(

Brian
 

MsftMan

Registered
Thanks Brian,

I just didn't know why you had chosen:
Dim objRecips As SafeRecipients over the original Dim objRecips As Outlook.Recipients

Steve
 

MsftMan

Registered
Hi Bill,

Over here in Covington, WA. Happy Holidays neighbor! The code I had used first would just stop running at the first instance of the ObjWFMail code then goes into debug mode with the referenecd line highlighted in yellow. I've since taken it out.

No biggy, the other code is OK... just have to turn the security on each time it's used. Again not a real issue.

Steve
 

lhuney1034

Registered
Macros not working with application

Hey Bill,

Any suggestion on how to get macros enabled as I continually get message "Macros are not enabled for this application". I'm sure this is a simple fix of which I'm not aware. Thanks for any help.

H
 

MsftMan

Registered
Re: Macros not working with application

lhuney1034 said:
Hey Bill,

Any suggestion on how to get macros enabled as I continually get message "Macros are not enabled for this application". I'm sure this is a simple fix of which I'm not aware. Thanks for any help.

H
Try altering your Security settings. Tools, Macro, Security, then set to Medium. You are probably at high or very high currently.

Steve Banks
 
A

Anonymous

Guest
tracking waiting fors

This code has prompted an idea that I don't know if it is possible, but would be a total success.

- As email arrives verify if the subject and sender matches an item in the waiting for folder (Subject and To).
- If it does open the received email and the waiting for tast
- Request confirmation from the user to mark the waiting for task as complete.

This would allow a semi-automatic confirmation to delegated tasks.

Any ideas

I would take a stab with VB but I am worthless in that regard (one of my new year resoltuions, though).

Xoff
 
F

fionamac

Guest
error for the macro to be used with the rules wizard

:shock: I'm getting an error
that the script does not exist or invalid when I use the one for combination with a rule.

Any ideas?

Regards, Fiona
 
Top