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.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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
 

bermudamohawk

New Member
Outlook version
Outlook 2013 64 bit
Email Account
POP3
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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
do you have this line at the top:
Public WithEvents OlItems As Outlook.Items

and have it in thisoutlooksession?
 

bermudamohawk

New Member
Outlook version
Outlook 2013 64 bit
Email Account
POP3
added, and it cleared the runtime error
F8 just loops the Initialize_handler sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
oh, that's right - it's triggered by the change event.

This is how it's supposed to work:
 

bermudamohawk

New Member
Outlook version
Outlook 2013 64 bit
Email Account
POP3
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.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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.
 

bermudamohawk

New Member
Outlook version
Outlook 2013 64 bit
Email Account
POP3
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?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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?
 

bermudamohawk

New Member
Outlook version
Outlook 2013 64 bit
Email Account
POP3
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.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
BTW, as written, it only works with messages in the identified folder, not in subfolders.
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Is there an easy way to make it watch all folders?
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
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.
 

bermudamohawk

New Member
Outlook version
Outlook 2013 64 bit
Email Account
POP3
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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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
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 New Slipstick.com Articles 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
V Flag related messages Using Outlook 4
B choosing flag status as a field for my inbox Using Outlook 1
C Can't "Arrange By" Outlook 2010 Inbox by Flag Status Using Outlook 2
M Flag outgoing mail by word in body Outlook Wishlist 1
D Follow up flag only displays Set Flag, Clear Flag. Missing Today, Tomorrow, This Week, Next Week, No Using Outlook 2
A Flag Status? Are you serious? Using Outlook 6
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
W September 2020 - No Default Email Client message after Office Update Using Outlook 1
S Outlook (2016 32bit; Gmail IMAP) - Save sent message to Outllook Folder Outlook VBA and Custom Forms 0
C Why won't Title display in message list? Using Outlook 1
icacream content in this message could not be downloaded.... Using Outlook 2
J Outlook 2016 After a search in all mailboxes, where is each message that was found? Using Outlook 6
R Warn before sending message Outlook VBA and Custom Forms 4
T Column to display which email alias a message was sent to Outlook VBA and Custom Forms 6
V Change start time based on message duration Outlook VBA and Custom Forms 2
J Message search and edit, another way? Outlook VBA and Custom Forms 4
N VBA to delete duplicates by message-id on common pst for 2 or more emails Outlook VBA and Custom Forms 0
S Create A Search Folder That Looks For Message Class? Outlook VBA and Custom Forms 0

Similar threads

Top