on flag message event - create task

Status
Not open for further replies.

bermudamohawk

New Member
Outlook version
Outlook 2013 64 bit
Email Account
POP3
There seems to be lots of proposed solutions to this, however - all create a "to-do" list item
To-Do lists do not show in iphone Tasks (activeSynch)

Need a vba snippet to create new TASK on set flag event.

Article here appears to be the best descriptor, but this (again) only creates a to-do list item.

thx for any consideration.
 
That macro does what you want - it creates a task when you flag a message. It will show in the to-do list (all tasks do) but it's an actual task.

this says do something when the item changes (the change is setting the flag) -
Private Sub OlItems_ItemChange(ByVal Item As Object)
If Item.IsMarkedAsTask = True Then

this tells you where to create it (default task folder) - if you wanted it in a different task folder, make the change here
Set olTask = Ns.GetDefaultFolder(olFolderTasks) .Items.Add(olTaskItem)

this creates the task -
With olTask
.Subject = Item.Subject
.Attachments.Add Item
.Body = Item.Body
.DueDate = Now + 1
.Save
.Display
End With

this removes the flag (that triggered the macro).
With Item
.ClearTaskFlag
.Categories = "Task"
.Save
End With
 
groundhog day.
still showing as to-do (as you said it would) - however - tasks are empty
"trade you" email subject flag set
resulting in:
upload_2015-10-5_13-7-56.png


Tasks remain unpopulated (all containers, if any doubt)
upload_2015-10-5_13-11-45.png


The behavior exhibited is default in MSOutlook 2013, so while i'm sure the code does something (as you explained) the end result is .. really nothing.
Sorry
 
it looks like its not working at all - if it works, this line: .Display displays the task on screen so you'd know it is working.


Step through it using F8 and see what it is skipping.

is macro security set to low?
click in this macro and press the run button:
Public Sub Initialize_handler()
Set OlItems = Application.GetNamespace("MAPI"). _
GetDefaultFolder(olFolderInbox).Items
End Sub
 
do you have this line at the top:
Public WithEvents OlItems As Outlook.Items

and have it in thisoutlooksession?
 
added, and it cleared the runtime error
F8 just loops the Initialize_handler sub
 
oh, that's right - it's triggered by the change event.

This is how it's supposed to work:
 
Really tantalizing to see it behave properly!

Added Dim's .. essentially copied screen ver batim.
Also removed Tasks from other accounts, so there is only one.

Still Groundhog Day here.
 
If you copied the entire macro and put it into ThisOutlooksession and have macro security set to low, it should work just list it does in the video.

You might need to either click in the initilize macro and click Run or restart outlook though.
 
If you copied the entire macro and put it into ThisOutlooksession > done
and have macro security set to low > done (in Word, also - just in case)
it should work just list it does in the video. > ummm - nope

You might need to either click in the initilize macro and click Run > tried
or restart outlook though. > tried


OK, since that is a mystery as to why not .. Is it possible to create a workaround?
Copy exiting to-do into Tasks?
 
I'm not aware of any workarounds.
All of the code is purple and black? No red?

There is no 'on error resume next' to skip it if there was an error, so it looks like this isn't watching the default inbox
Public Sub Initialize_handler()
Set OlItems = Application.GetNamespace("MAPI"). _
GetDefaultFolder(olFolderInbox).Items
End Sub

Ah... that could be the problem. How many inboxes do you have an what folder do you want it to watch?
 
here's what I'm seeing:

upload_2015-10-6_13-40-3.png




I have multiple containers under Inbox (like everyone, I assume)

upload_2015-10-6_13-42-25.png



I have 5 archived psts, also. But I'm certain they wouldn't affect the code.

I could try killing them.
 
Removing the pst files would only help if one is set as the default data file.

The macro uses the default data file's inbox. This line of code needs changed if you want to use a different folder:
Set OlItems = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items

accounts.png
 
BTW, as written, it only works with messages in the identified folder, not in subfolders.
 
Keep in mind, after every change of the code the "initalize_handler" should be called, which isn't called automatically at startup. Better name it Application_Startup
 
Is there an easy way to make it watch all folders?
 
You'd need to move the event to a class module, loop through the entire folder hierarchy and create one object of that class for every folder. Use a collection in ThisOutlookSession to store the reference on each object of your class module. Here is a sample for the loop through all folders.
 
if this is of any consequence, action would only be performed on elements in default inbox - no other containers.
Perhaps that could be on someone else's wishlist
 
You'd need to move the event to a class module, loop through the entire folder hierarchy and create one object of that class for every folder. Use a collection in ThisOutlookSession to store the reference on each object of your class module. Here is a sample for the loop through all folders.
I asked for easy. :)
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
A Flag Message for Follow Up after sending Outlook VBA and Custom Forms 1
R Call a Public Sub when a Flag is clicked on in the Message Preview pane Outlook VBA and Custom Forms 1
A automatically remove flag from original message when a response was received Using Outlook 2
M How can I customize the Follow Up Flag message in Quick Steps? Using Outlook 1
L Help: set flag for sent mail to check if received an answer Outlook VBA and Custom Forms 2
E Remove flag automatically Using Outlook 4
justicefriends How to set a flag to follow up using VBA - for addressee in TO field Outlook VBA and Custom Forms 11
T Can't reposition "Flag Status" column Using Outlook 0
R Outlook 365 update sets delete from server flag Using Outlook 1
S Change "This Week" flag start date behavior Using Outlook 1
C-S-R How to clear an Outlook (To Do) Task Flag? Using Outlook 8
A Unflag Inbox and Flag Inbox with Orange Category After Item is send Outlook VBA and Custom Forms 3
N Outlook 2010 Flag blocked for Safe Senders List???? Using Outlook 7
Rupert Dragwater Email flag does not show up in Outlook2013 Using Outlook 13
J Outlook 2013 Extract Flag Completed dates to Excel Macro Outlook VBA and Custom Forms 16
M Setting flag follow up for next business day Outlook VBA and Custom Forms 1
M VBA to change flag status in outlook contact item Outlook VBA and Custom Forms 3
A rule to flag messages not working Using Outlook 5
S set a flag task date as the next weekday Outlook VBA and Custom Forms 4
G Flag for Follow Up with a customized duetime Using Outlook 1
Diane Poremsky How to Easily Change the Private Flag Using Outlook 0
A Flag outgoing email messages in Outlook 2010 Outlook VBA and Custom Forms 0
T Customize Outlook flag Using Outlook 1
mikolajek Add on for customized flag operations? Using Outlook 4
Norbert VBA Flag that would indicate the email was sent from Outlook to Access. Outlook VBA and Custom Forms 2
A Custom Flag Form Outlook VBA and Custom Forms 2
S Have Rule or Quick Step PROMPT for custom FLAG Due/Reminder date Outlook VBA and Custom Forms 3
mikecox Missing alarm flag Using Outlook 2
smokiibear follow-up flag fro Tasks in Outlook 2010 Using Outlook 5
D Create additional custom flag descriptions (other than Send E-Mail, Call etc.) Using Outlook 1
L VBA Macro to flag sent emails Using Outlook 1
A Post Form Follow Up Flag Using Outlook 4
S Flag Completion Using Outlook 0
J How to set a flag to follow up using VBA for outlook 2003 Using Outlook 10
F Apply Follow up flag ONLY to the people cc'd. Using Outlook 1
J Macro to periodically sort emails by flag status? Using Outlook 1
2 Flag for Follow up or create new task Using Outlook 1
L Flag settings Using Outlook 1
D Setting the Reminder flag in VBA for e-Mails sent to users Outlook VBA and Custom Forms 5
S Adding follow flag for me by macro (MSO2007) Outlook VBA and Custom Forms 3
M Search message, then (1) Jump to folder & (2) Select message that you searched for Outlook VBA and Custom Forms 2
Kika Melo How to mark as Junk any message not from Contacts (in Outlook.com) Using Outlook 3
G Outlook 365 My iCloud Outlook doesn’t work after reinstalling Microsoft365 on Windows 10 PC – now I get error message on contacts and calendar Using Outlook 1
G Get current open draft message body from VBA Outlook VBA and Custom Forms 1
E Outlook 365 Save Selected Email Message as .msg File - oMail.Delete not working when SEARCH Outlook VBA and Custom Forms 0
HarvMan Outlook 365 - Rule to Move an Incoming Message to Another Folder Using Outlook 4
F Outlook 2019 Forwarding Message and Keeping Unread Status Outlook VBA and Custom Forms 0
E Save Selected Email Message as .msg File - digitally sign email doesn't works Outlook VBA and Custom Forms 1
C Populate form data into message body Outlook VBA and Custom Forms 1
J Outlook 365 Add keywords from Listbox to the message body where cursor is placed Outlook VBA and Custom Forms 0

Similar threads

Back
Top