I've looked at a variety of your codes and found one that will automatically create a task based on sending an email that contains a category - I will paste it below with my minor changes. To use, select the message and run the macro. Simply change the Set objMail line to Set objMail = GetCurrentItem() and get the GetCurrentItem function from " Outlook VBA: Work with Open Item or Selected Item". ![]() This code doesn't work with open messages, but a little more tweaking can change that. When you are reading a message in the reading pane, you can click the button to create a task. To use it, create a command on the ribbon or toolbar and assign the macro to it. To do this, we needed to modify the original code just a little. ![]() Jason wanted to know if we could use the code with a button to create a task from a selected message. When a new message arrives meeting the conditions in the rule, the script runs and creates a task out of the message. Set objTask = (olTaskItem)Ĭreate a rule using the condition and choose the action "Run a Script", choosing the ConvertMailtoTask script you pasted into the VBA editor. Set SPSFolder = GetFolderPath("SharePoint Lists\Slipstick - Tasks") ' You need the GetFolderpath function from See Working with non-default Outlook Folders for more information. Set SPSFolder = Session.GetDefaultFolder(olFolderTasks).Folders("Subfolder Name") When the folder is a subfolder under the default Tasks folder, use this: Set SPSFolder = Session.GetDefaultFolder(olFolderTasks).Parent.Folders("Task folder Name") When the folder is the same level as the Tasks folder, using the example below. You can also use a different folder in the mailbox. This example saves it to a Task folder in a different data file, in this case, a Sharepoint task list that is linked to Outlook. You can save the task to a different folder by adding two lines to the code. Instructions are at Using Arrays with Outlook macros. To assign different categories based on different keywords in the subject, you can use an IF statement for a couple of keywords but should use an array for a larger number of keywords. This is easy if you want one category for all tasks - just place this line before the objTask.Save line: Set myDelegate = ("alias")Ĭarol asked how to add a category to the tasks. The DIM statement goes at the top of the macro with the other DIM statements. If you use the user's name or alias, you may need to Resolve it using code before it's sent.Assign goes in the With objTask code block, but the Recipient is added outside of the With statement, then it's sent. Assign to the With objTask code block, along with. I recommend using the address only because it can't resolve to the wrong person. You can use either the full email address or the GAL alias, or even the person's display name, provided the name can resolve to an entry in your address book or GAL. If you want to send a Task Request, you need to Assign it and add the Recipient. Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolderįor Each objAtt In objSourceItem.Attachments Set fso = CreateObject("Scripting.FileSystemObject") Sub CopyAttachments(objSourceItem, objTargetItem) Then this after the end of the first macro: ![]() To copy attachments from the messages to the task, you need to use the CopyAttachments, added to the end of the task macro. To add the item as an attachment to the task, add the following lines after the Item.Body line: ObjTask.ReminderTime = objTask.DueDate - 0.25Ĭreate a task using a Run a Script rule video tutorial If a reminder time is not set, it will use the default setting for Tasks, usually 8 am on the due date.Īccepted values for ReminderSet are True (on) or False (no reminder) This example creates a reminder for 6 hrs before the due date or 6 pm the day before. To override your default settings for Task reminders (set in Options, Tasks), you can use the ReminderSet and ReminderTime properties. ReminderTime = Date 2.25 ' remind at 6 AM 2 days from now To use today's date only, not the current time, use Date and decimals to set the due date or reminder time. ObjTask.StartDate = Item.ReceivedTime 2 If you use a category that is not in your Categories list, the color category field in the view will be colorless as the category is not in the master list. If you prefer to change the Start date, you would add a whole number to the start date line. To calculate the due date, you'll use the DueDate property and add a whole number to the Received date. You can customize the script to set a category or due date (or any other fields supported in Tasks). Set objTask = Application.CreateItem(olTaskItem) Sub ConvertMailtoTask(Item As Outlook.MailItem) Paste this code into the VBA editor then create a rule and choose Run a script as the action. Press Alt F11 to open the VBA editor and expand the tree to find ThisOutlookSession.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |