(Msg. 1) Posted: Fri Aug 08, 2008 8:28 pm
Post subject: Email to Task, move task to 'Other Tasks' folder to sync w/Sharepoint Archived from groups: microsoft>public>outlook>program_vba (more info?)
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.
(Msg. 2) Posted: Sat Aug 09, 2008 4:26 am
Post subject: RE: Email to Task, move task to 'Other Tasks' folder to sync w/Sharepo [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
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:
To see the path for any folder, use View | Toolbars to display the Web
toolbar. The folder's path (prefixed with outlook:) will be displayed in the
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.
(Msg. 3) Posted: Mon Aug 11, 2008 9:36 pm
Post subject: Re: Email to Task, move task to 'Other Tasks' folder to sync w/Sharepoint [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
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?
(Msg. 4) Posted: Mon Aug 25, 2008 9:55 pm
Post subject: RE: Email to Task, move task to 'Other Tasks' folder to sync w/Sharepo [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
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)
'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
'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
All times are: Eastern Time (US & Canada) (change)
Page 1 of 1
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum