![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
I need a VBA script that is executed via an Outlook 2007 rule when a specific
type of email is received (from a specific account, containing specific text). The script should create an Outlook task with elements from the original email (plus include the original email as an attachment), then move the task to an 'Other Tasks' folder. I have seen code somewhere that will created a task item from an email item. But I have not seen anything that moves the task to a separate task folder which, in this case, will synchronize with a Sharepoint 2007 site's task list. Caveat: I know very little about programing VBA. Ideas? |
Ads |
#2
|
|||
|
|||
![]()
To create a new item in a non-default folder programmatically, use the Add
method on the target folder's Items collection: Set newItem = targetFolder.Items.Add("IPM.Task.YourFormName") To get a non-default folder (the targetFolder object), you need to walk the folder hierarchy using the Folders collections or use a function that does that for you. For examples, see: http://www.outlookcode.com/d/code/getfolder.htm - uses a folder path string http://www.outlookcode.com/codedetail.aspx?id=492 - searches for a folder by name To see the path for any folder, use View | Toolbars to display the Web toolbar. The folder's path (prefixed with outlook ![]() address control on that toolbar. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming: Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "mitcham" wrote: I need a VBA script that is executed via an Outlook 2007 rule when a specific type of email is received (from a specific account, containing specific text). The script should create an Outlook task with elements from the original email (plus include the original email as an attachment), then move the task to an 'Other Tasks' folder. I have seen code somewhere that will created a task item from an email item. But I have not seen anything that moves the task to a separate task folder which, in this case, will synchronize with a Sharepoint 2007 site's task list. Caveat: I know very little about programing VBA. |
#3
|
|||
|
|||
![]() To move an item use its Move function. Please see the VBA help for a code sample. -- Best regards Michael Bauer - MVP Outlook : VBOffice Reporter for Data Analysis & Reporting : Outlook Categories? Category Manager Is Your Tool : http://www.vboffice.net/product.html?pub=6&lang=en Am Fri, 08 Aug 2008 20:28:49 GMT schrieb mitcham: I need a VBA script that is executed via an Outlook 2007 rule when a specific type of email is received (from a specific account, containing specific text). The script should create an Outlook task with elements from the original email (plus include the original email as an attachment), then move the task to an 'Other Tasks' folder. I have seen code somewhere that will created a task item from an email item. But I have not seen anything that moves the task to a separate task folder which, in this case, will synchronize with a Sharepoint 2007 site's task list. Caveat: I know very little about programing VBA. Ideas? |
#4
|
|||
|
|||
![]()
the following code contains two Subs,
Assign sub will: - create the task - add the email entry ID as a property to the task (as a reference) - Attach the email to the task. - Flag the orignal e-mail and add "Assigned task" to the top Complete sub will: - clear the flag from the email when the task is completed. hope this will help... here is the code Sub Assign() 'Get a reference to the MAPI namespace Dim objNS As Outlook.NameSpace Set objNS = Application.GetNamespace("MAPI") ' Get a reference to the currently selected Outlook folder Dim currentFolder As Outlook.MAPIFolder Set currentFolder = Application.ActiveExplorer.currentFolder ' Make sure at least one item is selected If Application.ActiveExplorer Is Nothing Then MsgBox "Please select an item" Exit Sub End If If Application.ActiveExplorer.Selection Is Nothing Then MsgBox "Please select an item" Exit Sub End If 'Get Selected Item Dim oItem As Outlook.MailItem Set oItem = Application.ActiveExplorer.Selection(1) 'Flag E-mail oItem.FlagIcon = olBlueFlagIcon oItem.FlagStatus = olFlagMarked oItem.FlagRequest = "Assinged task on " & Now() 'Create a new task Dim oTask As Outlook.TaskItem Set oTask = Application.CreateItem(olTaskItem) 'Map task to e-mail using Email entry ID Dim oProp As Outlook.UserProperty Set oProp = oTask.UserProperties.Add("EmailEntryID", olText, True) oProp.Value = oItem.EntryID 'Assing task properties oTask.Subject = oItem.Subject oTask.StartDate = Now() oTask.Status = olTaskNotStarted oTask.Attachments.Add oItem, olByValue oTask.Assign 'open task oTask.Display 'clear objects from the memory Set objNS = Nothing Set currentFolder = Nothing Set oItem = Nothing Set oTask = Nothing Set oProp = Nothing Set ojbAtt = Nothing End Sub Sub Complete() On Error GoTo e 'Get a reference to the MAPI namespace Dim objNS As Outlook.NameSpace Set objNS = Application.GetNamespace("MAPI") ' Get a reference to the currently selected Outlook folder Dim currentFolder As Outlook.MAPIFolder Set currentFolder = Application.ActiveExplorer.currentFolder 'Get current task Dim oSels As Outlook.Selection Set oSels = Application.ActiveExplorer.Selection Dim oTask As Outlook.TaskItem Dim oProp As Outlook.UserProperty Dim oEmail As Outlook.MailItem For Each oSel In oSels If oSel.Class = olTask Then Set oTask = oSel 'Get referenced e-mail attached to the task Set oProp = oTask.UserProperties.Find("EmailEntryID") 'Get e-mail by EntryID Set oEmail = objNS.GetItemFromID(oProp.Value) 'Flag e-mail as compeleted oEmail.FlagRequest = "Task Compeleted on " & Now() oEmail.FlagIcon = olNoFlagIcon oEmail.FlagStatus = olFlagComplete 'save changes oEmail.Save Set oTask = Nothing Set oProp = Nothing Set oEmail = Nothing End If Next MsgBox "referenced e-mail has been flaged for completion successfully" GoTo x e: MsgBox Err.Description x: 'clear objects from the memory Set objNS = Nothing Set currentFolder = Nothing Set oTask = Nothing Set oProp = Nothing Set oEmail = Nothing End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Code to move task from inbox to a task folder | LDMueller | Outlook and VBA | 3 | April 18th 08 06:14 PM |
On completion of a task, can I email a copy of the task to myself | Richard T | Outlook and VBA | 1 | June 15th 07 07:08 AM |
Differentiate between drag & drop email task creation and normal task creation | Mohit | Add-ins for Outlook | 1 | April 18th 07 06:54 AM |
2 simple macros - create task from email and move email to folder | [email protected] | Outlook and VBA | 5 | February 4th 07 10:57 AM |
How do I move a Daily Task to the Master Task List? | Carol | Outlook - General Queries | 0 | November 17th 06 06:57 PM |