Task not visible in SharePoint

Status
Not open for further replies.

pabe1250

Member
Outlook version
Outlook 2007
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

 

pabe1250

Member
Outlook version
Outlook 2007
Email Account
Exchange Server
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
 

pabe1250

Member
Outlook version
Outlook 2007
Email Account
Exchange Server
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?
 

Diane Poremsky

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

pabe1250

Member
Outlook version
Outlook 2007
Email Account
Exchange Server
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.
Top