Task not visible in SharePoint

Status
Not open for further replies.

pabe1250

Member
Outlook version
Email Account
Exchange Server
Hi!

The code below converts incoming mail in Outlook to a task and moves the task to a SharePoint-list. So far so good:)

When the task appears in the SharePoint-list it should be given a status (Not Started, Started, Completed) automatically. This is a requirement to make the line visible when connecting to the SharePoint-list through a browser.

My problem seems to be that the task is moved into the SharePoint-list without any status what so ever, thus not visible. The solution is to manually click on "Tasks" in Outlook and then return by clicking the SharePoint-list in Outlook. Then the task changes from no status at all to "Not Started".

Is there any way to have the task set to "Not Started" as default behaviour automatically - perhaps by adding some code to the macro?

Sub ConvertMailtoTask(Item As Outlook.MailItem)

Dim objTask As Outlook.TaskItem
Set objTask = Application.CreateItem(olTaskItem)

'move this up here just to get it out of the way
Set SPSFolder = GetFolderPath("SharePoint-lists\Any_given_folder")

' this creates and saves the task

With objTask
.Subject = Item.Subject
.StartDate = Item.ReceivedTime
.Body = Item.Body
.Save
End With

' this can go right before 'end with' (if so remove ojbtask from it)
objTask.Move SPSFolder


' this goes last, before the sub ends
Set objTask = Nothing


End Sub



Function GetFolderPath(ByVal FolderPath As String) As Outlook.Folder


Dim oFolder As Outlook.Folder

Dim FoldersArray As Variant

Dim i As Integer

On Error GoTo GetFolderPath_Error

If Left(FolderPath, 2) = "\\" Then

FolderPath = Right(FolderPath, Len(FolderPath) - 2)

End If

'Convert folderpath to array

FoldersArray = Split(FolderPath, "\")

Set oFolder = Application.Session.Folders.Item(FoldersArray(0))

If Not oFolder Is Nothing Then

For i = 1 To UBound(FoldersArray, 1)

Dim SubFolders As Outlook.Folders

Set SubFolders = oFolder.Folders

Set oFolder = SubFolders.Item(FoldersArray(i))

If oFolder Is Nothing Then

Set GetFolderPath = Nothing

End If

Next

End If

'Return the oFolder

Set GetFolderPath = oFolder

Exit Function

GetFolderPath_Error:

Set GetFolderPath = Nothing

Exit Function

End Function

 
I think I am getting closer now. Please look in to this code:

Sub ConvertMailtoTask(Item As Outlook.MailItem)

Dim objTask As Outlook.TaskItem
Set objTask = Application.CreateItem(olTaskItem)

Dim strStatus, strPriority

'move this up here just to get it out of the way
Set SPSFolder = GetFolderPath("SharePoint-lists\Any_given_folder")

'other task defaults
strStatus = 0
strPriority = 1


' this creates and saves the task

With objTask
.Subject = Item.Subject
.StartDate = Item.ReceivedTime
.Status = strStatus
.Importance = strPriority

.Body = Item.Body
.Save
End With

' this can go right before 'end with' (if so remove ojbtask from it)
objTask.Move SPSFolder


' this goes last, before the sub ends
Set objTask = Nothing


End Sub

Shouldn't these adjustments make the task set to status "Not started" and "Normal" and thus become visible?

Well, it's not:(

Any ideas?

/Paul
 
SharePoint tasks use a custom status & custom priority field and i assume that is why its not working. Add the status and priority fields to the view, along with the 2 custom fields and see if the values are synced.
 
Diane,

you lost me there....

I assume your idea means that the custom status and custom priority fields should be integrated in the current macro. But how? I'm really on a beginner's level when it comes to this.

"Add the status and priority fields to the view"....?.....they are already visible both in Outlook and SharePoint....but when the macro has executed their values seem to be NULL/unset.

When I manually click the task directory then both values are set. That means that by doing so the "Status" from Outlook becomes a "Custom status" in SharePoint.

Do you mean I should put the custom fields in the code above? Using strCustomStatus and strCustomPriority - or?

You're discussing something about it here; http://www.slipstick.com/outlook/tasks/custom-priority-field/

Is this sufficient to make it work or does it need some more coding?
 
in looking with outlookspy, these are the property accessors -

http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/8137001F

http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/8138001F

These two should point you in the right direction on how to use them - MSDN shows how to read and write:

MSDN: http://msdn.microsoft.com/en-us/library/office/bb176395(v=office.12).aspx

OutlookCode: http://www.outlookcode.com/threads.aspx?forumid=4&messageid=27801
 
Well, I'm sorry:(

I tried the code upside and down without getting any compilation errors, but still the status/priority don't get pasted into the custom status/priority, thus remains invisible in SharePoint.

Thanks for your effort.

/Paul
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
P Task in SharePoint-list not visible to colleagues Using Outlook 1
S Create Outlook Task from Template and append Body with Email Body Outlook VBA and Custom Forms 4
D Copy Appointment Body to Task Body Outlook VBA and Custom Forms 0
K Daily Task List Minimized Cannot Display Using Outlook 5
wayneame Changing the Form Used by Existing Task Items in a Folder Outlook VBA and Custom Forms 4
S Outlook 2016 Understand and customize prepended behavior of recurring task Using Outlook 0
B Outlook 365 Populate Outlook Task UDFs from a UDF text string Outlook VBA and Custom Forms 2
K Multiple copies of task being created Using Outlook 2
P Short Date Format when typing in a task Using Outlook 2
C Outlook 2013 Task Recurrence - Third Friday After the Second Tuesday Using Outlook 2
P Task display now leaves little room for notes Using Outlook 10
C-S-R How to clear an Outlook (To Do) Task Flag? Using Outlook 8
G Event when creating task from mailitem Outlook VBA and Custom Forms 2
P Changing the font that the task view shows Using Outlook 5
D How To Combine Share Task Folders in just one Folder Using Outlook 0
P Can I create a Rule that sends me an email when I get a Task? Using Outlook 2
G Arggh, weakness of reminder for every Task recurrence Using Outlook 0
P Can't paste an image into a task Using Outlook 3
F Validation on custom task form after task acceptance Outlook VBA and Custom Forms 1
J Office 365 erased all of my task views Using Outlook 3
T Report For Task Recurrance Outlook VBA and Custom Forms 4
E Can't accept or decline task (no button appears) Using Outlook 2
Z VBA to convert email to task, insert text of email in task notes, and attach copy of original email Outlook VBA and Custom Forms 4
Z Task Filter Not Working When I add too many criteria Using Outlook 0
X If you change expiration date of repeated task it dupplicates Using Outlook 1
Z How to show concatenated categories in list task view? Using Outlook 2
Z VBA to Collapse Task Folder Groups Outlook VBA and Custom Forms 1
E To convert imported data to custom fields in Task list Outlook VBA and Custom Forms 1
I Help with dates in task list. Using Outlook 5
Y Outlook Task View - Table Format - Customize Reminder Time to Drop-Down Selection Using Outlook 2
M Daily Task List Minimized Cannot Display Using Outlook 2
D Using a VBA Custom Form to Send Reoccurring Email Upon Task Completion Outlook VBA and Custom Forms 4
P Add a contact to the New Task in Outlook 2016 Using Outlook 2
S Codes for "Mark Complete" the task Outlook VBA and Custom Forms 2
W Deleting Sent Task Email, Deletes the task from my list Using Outlook 1
K Task priority modification Using Outlook 4
F Search folder for tasks in all task folders Using Outlook 1
JohnViuf Export task list view settings to other pc Outlook VBA and Custom Forms 16
V Changing default date for task follow-up buttons Using Outlook 2
K outlook workflow: automated task generation Outlook VBA and Custom Forms 4
U HTML Task Alternate Home Page View Control Using Outlook 3
F How to assign a task to a public task folder? Using Outlook 1
J Marketing task MS BCM BCM (Business Contact Manager) 10
copperberry How to view all tasks across task folders Using Outlook 3
P Task Categories Using Outlook 2
P Run Time Error 91 when linking contact to task in VBA Outlook VBA and Custom Forms 1
L Email to task without changin formatting Outlook VBA and Custom Forms 16
S BCM Project Task Order BCM (Business Contact Manager) 1
P Custom form reverts from task Outlook VBA and Custom Forms 1
evdbogaard How to dock the Styles Task Pane in the e-mail editing window? Outlook VBA and Custom Forms 1

Similar threads

Back
Top