![]() |
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
|
|||
|
|||
![]()
Hello,
I need to collect some tasks in a task folder to build a status e-mail. Acctualy, I did it very well, but the sort classification are ignored. How can i collect the tasks respecting the sort order? Thank's in advance. --- Here is the code: Const C_ROOTITEM = 1 Dim oRoot As Outlook.Folder Dim oFila As Outlook.Folder Dim oEquipe As Outlook.Folder Dim colInProgress As New Collection Dim colWaiting As New Collection Dim colNotStarted As New Collection Dim oTask As taskItem Dim oContact As ContactItem Dim colDestinatários As New Collection Dim colEmCópia As New Collection Dim oNovoMail As MailItem Dim strTo As String Dim strCC As String Dim strCorpo As String Public Sub ReportAll() ' collect tasks and recipients Set colInProgress = GetTasksByStatus(olTaskInProgress) Set colNotStarted = GetTasksByStatus(olTaskNotStarted) Set colWaiting = GetTasksByStatus(olTaskWaiting) Set colDestinatários = GetRecipientsByJobTitle("LÃ*der") Set colEmCópia = GetRecipientsByJobTitle("Gerente") ' build a new e-mail Set oNovoMail = Application.CreateItem(olMailItem) oNovoMail.To = BuildRecipientList(colDestinatários) oNovoMail.CC = BuildRecipientList(colEmCópia) oNovoMail.Subject = "Fila de Validações" '@@ '@@ e-mail body '@@ strCorpo = "" ' Introdução strCorpo = "Pessoal," strCorpo = strCorpo + Chr(13) strCorpo = strCorpo + Chr(13) strCorpo = strCorpo + "Segue a fila da validações" strCorpo = strCorpo + Chr(13) strCorpo = strCorpo + "Caso tenham alguma urgência, comuniquem-me imediatamente que eu repriorizo na hora" strCorpo = strCorpo + Chr(13) ' to-do itens If colNotStarted.Count 0 Then strCorpo = strCorpo + Chr(13) strCorpo = strCorpo + "A REVISAR" strCorpo = strCorpo + Chr(13) + Chr(13) For Each oTask In colNotStarted strCorpo = strCorpo + oTask.Subject & " (" & oTask.ContactNames & ")" & Chr(13) Next End If ' on going itens If colInProgress.Count 0 Then strCorpo = strCorpo + Chr(13) strCorpo = strCorpo + "EM REVISÃO" strCorpo = strCorpo + Chr(13) + Chr(13) For Each oTask In colInProgress strCorpo = strCorpo + VerboseTask(oTask) & Chr(13) Next End If ' waiting itens If colWaiting.Count 0 Then strCorpo = strCorpo + Chr(13) strCorpo = strCorpo + "AGUARDANDO RETORNO" strCorpo = strCorpo + Chr(13) + Chr(13) For Each oTask In colWaiting strCorpo = strCorpo + VerboseTask(oTask) & Chr(13) Next End If strCorpo = strCorpo + Chr(13) strCorpo = strCorpo + "Obrigado," strCorpo = strCorpo + Chr(13) strCorpo = strCorpo + "Lorenzo" oNovoMail.Body = strCorpo '@@ '@@ show the e-mail to send '@@ oNovoMail.Recipients.ResolveAll oNovoMail.Display End Sub '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ' ' TOOLS FUNCTIONS ' '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Public Sub GotoFilaNatura() ' Abre a fila Natura Dim oFila As Outlook.Folder Call SetRoot Set oFila = GetFolder("FilaNatura", oRoot) oFila.Display End Sub Public Sub SetRoot() ' Retorna a raiz da pasta local. ' Esta função garante que a aplicação trabalhe sempre com uma pasta especÃ*fica Dim colStores As Outlook.Stores Dim oStore As Outlook.Store Dim oTempRoot As Outlook.Folder On Error Resume Next Set colStores = Application.Session.Stores For Each oStore In colStores Set oTempRoot = oStore.GetRootFolder If oTempRoot.Name = "Personal Folders" Then Set oRoot = oTempRoot End If Next End Sub Public Function GetFolder(ByVal folderName As String, oBase As Outlook.Folder) As Outlook.Folder ' Passando um nome, retorna um ponteiro para o folder com o mesmo nome ' Em qualquer nÃ*vel de profundidade. Dim folders As Outlook.folders Dim Folder As Outlook.Folder Dim foldercount As Integer On Error Resume Next Set folders = oBase.folders foldercount = folders.Count 'Check if there are any folders below oFolder If foldercount Then For Each Folder In folders If Folder.Name = folderName Then Set GetFolder = Folder Else GetFolder folderName, Folder End If Next End If End Function '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ' ' QUERY FUNCTIONS ' '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Public Function GetTasksByStatus(ByVal targetStatus As Variant) As Collection ' Retorna todos os itens da fila que tenham um stats especÃ*fico Dim colNewCollection As New Collection Dim taskIndex As taskItem ' Obtém os repositórios Call SetRoot Set oFila = GetFolder("FilaNatura", oRoot) Set colNewCollection = Nothing For Each taskIndex In oFila.Items If taskIndex.Status = targetStatus Then colNewCollection.Add taskIndex End If Next Set GetTasksByStatus = colNewCollection End Function Public Function GetRecipientsByJobTitle(ByVal targetRole As Variant) As Collection ' Retorna todos as pessoas que tenham um job title especÃ*fico Dim colNewCollection As New Collection Dim contactIndex As ContactItem ' Obtém os repositórios Call SetRoot Set oEquipe = GetFolder("EquipeNatura", oRoot) Set colNewCollection = Nothing For Each contactIndex In oEquipe.Items If contactIndex.JobTitle = targetRole Then colNewCollection.Add contactIndex End If Next Set GetRecipientsByJobTitle = colNewCollection End Function '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ' ' TRANSFORMATION FUNCTIONS ' '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Public Function BuildRecipientList(colRecipientsList As Collection) As String ' Coloca uma lista de pessoas em uma string separada por ponto-e-vÃ*rgula Dim strTo As String Dim contactIndex As ContactItem strTo = "" For Each contactIndex In colRecipientsList strTo = strTo + contactIndex.Email1DisplayName strTo = strTo + " ; " Next BuildRecipientList = strTo End Function Public Function VerboseTask(aTask As taskItem) As String ' Representa uma task em uma string Dim strResponsável As String Dim strNome As String strNome = aTask.Subject strResponsável = aTask.ContactNames VerboseTask = strNome & " (" & strResponsável & ")" End Function |
Ads |
#2
|
|||
|
|||
![]()
That's a lot of code to make someone look through, but I don't see any place
in it that you've called the Items.Sort method. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "lberendsen" wrote in message ... Hello, I need to collect some tasks in a task folder to build a status e-mail. Acctualy, I did it very well, but the sort classification are ignored. How can i collect the tasks respecting the sort order? Thank's in advance. --- Here is the code: Const C_ROOTITEM = 1 Dim oRoot As Outlook.Folder Dim oFila As Outlook.Folder Dim oEquipe As Outlook.Folder Dim colInProgress As New Collection Dim colWaiting As New Collection Dim colNotStarted As New Collection Dim oTask As taskItem Dim oContact As ContactItem Dim colDestinatários As New Collection Dim colEmCópia As New Collection Dim oNovoMail As MailItem Dim strTo As String Dim strCC As String Dim strCorpo As String Public Sub ReportAll() ' collect tasks and recipients Set colInProgress = GetTasksByStatus(olTaskInProgress) Set colNotStarted = GetTasksByStatus(olTaskNotStarted) Set colWaiting = GetTasksByStatus(olTaskWaiting) Set colDestinatários = GetRecipientsByJobTitle("Líder") Set colEmCópia = GetRecipientsByJobTitle("Gerente") ' build a new e-mail Set oNovoMail = Application.CreateItem(olMailItem) oNovoMail.To = BuildRecipientList(colDestinatários) oNovoMail.CC = BuildRecipientList(colEmCópia) oNovoMail.Subject = "Fila de Validações" '@@ '@@ e-mail body '@@ strCorpo = "" ' Introdução strCorpo = "Pessoal," strCorpo = strCorpo + Chr(13) strCorpo = strCorpo + Chr(13) strCorpo = strCorpo + "Segue a fila da validações" strCorpo = strCorpo + Chr(13) strCorpo = strCorpo + "Caso tenham alguma urgência, comuniquem-me imediatamente que eu repriorizo na hora" strCorpo = strCorpo + Chr(13) ' to-do itens If colNotStarted.Count 0 Then strCorpo = strCorpo + Chr(13) strCorpo = strCorpo + "A REVISAR" strCorpo = strCorpo + Chr(13) + Chr(13) For Each oTask In colNotStarted strCorpo = strCorpo + oTask.Subject & " (" & oTask.ContactNames & ")" & Chr(13) Next End If ' on going itens If colInProgress.Count 0 Then strCorpo = strCorpo + Chr(13) strCorpo = strCorpo + "EM REVISÃO" strCorpo = strCorpo + Chr(13) + Chr(13) For Each oTask In colInProgress strCorpo = strCorpo + VerboseTask(oTask) & Chr(13) Next End If ' waiting itens If colWaiting.Count 0 Then strCorpo = strCorpo + Chr(13) strCorpo = strCorpo + "AGUARDANDO RETORNO" strCorpo = strCorpo + Chr(13) + Chr(13) For Each oTask In colWaiting strCorpo = strCorpo + VerboseTask(oTask) & Chr(13) Next End If strCorpo = strCorpo + Chr(13) strCorpo = strCorpo + "Obrigado," strCorpo = strCorpo + Chr(13) strCorpo = strCorpo + "Lorenzo" oNovoMail.Body = strCorpo '@@ '@@ show the e-mail to send '@@ oNovoMail.Recipients.ResolveAll oNovoMail.Display End Sub '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ' ' TOOLS FUNCTIONS ' '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Public Sub GotoFilaNatura() ' Abre a fila Natura Dim oFila As Outlook.Folder Call SetRoot Set oFila = GetFolder("FilaNatura", oRoot) oFila.Display End Sub Public Sub SetRoot() ' Retorna a raiz da pasta local. ' Esta função garante que a aplicação trabalhe sempre com uma pasta específica Dim colStores As Outlook.Stores Dim oStore As Outlook.Store Dim oTempRoot As Outlook.Folder On Error Resume Next Set colStores = Application.Session.Stores For Each oStore In colStores Set oTempRoot = oStore.GetRootFolder If oTempRoot.Name = "Personal Folders" Then Set oRoot = oTempRoot End If Next End Sub Public Function GetFolder(ByVal folderName As String, oBase As Outlook.Folder) As Outlook.Folder ' Passando um nome, retorna um ponteiro para o folder com o mesmo nome ' Em qualquer nível de profundidade. Dim folders As Outlook.folders Dim Folder As Outlook.Folder Dim foldercount As Integer On Error Resume Next Set folders = oBase.folders foldercount = folders.Count 'Check if there are any folders below oFolder If foldercount Then For Each Folder In folders If Folder.Name = folderName Then Set GetFolder = Folder Else GetFolder folderName, Folder End If Next End If End Function '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ' ' QUERY FUNCTIONS ' '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Public Function GetTasksByStatus(ByVal targetStatus As Variant) As Collection ' Retorna todos os itens da fila que tenham um stats específico Dim colNewCollection As New Collection Dim taskIndex As taskItem ' Obtém os repositórios Call SetRoot Set oFila = GetFolder("FilaNatura", oRoot) Set colNewCollection = Nothing For Each taskIndex In oFila.Items If taskIndex.Status = targetStatus Then colNewCollection.Add taskIndex End If Next Set GetTasksByStatus = colNewCollection End Function Public Function GetRecipientsByJobTitle(ByVal targetRole As Variant) As Collection ' Retorna todos as pessoas que tenham um job title específico Dim colNewCollection As New Collection Dim contactIndex As ContactItem ' Obtém os repositórios Call SetRoot Set oEquipe = GetFolder("EquipeNatura", oRoot) Set colNewCollection = Nothing For Each contactIndex In oEquipe.Items If contactIndex.JobTitle = targetRole Then colNewCollection.Add contactIndex End If Next Set GetRecipientsByJobTitle = colNewCollection End Function '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ' ' TRANSFORMATION FUNCTIONS ' '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Public Function BuildRecipientList(colRecipientsList As Collection) As String ' Coloca uma lista de pessoas em uma string separada por ponto-e-vírgula Dim strTo As String Dim contactIndex As ContactItem strTo = "" For Each contactIndex In colRecipientsList strTo = strTo + contactIndex.Email1DisplayName strTo = strTo + " ; " Next BuildRecipientList = strTo End Function Public Function VerboseTask(aTask As taskItem) As String ' Representa uma task em uma string Dim strResponsável As String Dim strNome As String strNome = aTask.Subject strResponsável = aTask.ContactNames VerboseTask = strNome & " (" & strResponsável & ")" End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sort tasks by due date and category in to do list, daily task list | MLou | Outlook - Calandaring | 1 | June 12th 08 11:59 PM |
Sort list of views in Current View submenu? | Fastauntie | Outlook - Installation | 0 | February 7th 08 10:07 PM |
Task list in To Do List in the Calendar view | ang | Outlook - General Queries | 0 | February 10th 07 03:03 PM |
Task list view shows blanks in Outlook for two columns | Ripantuck | Outlook - General Queries | 1 | December 26th 06 04:52 AM |
View tasks on Calander days instead of only task list | Wes | Outlook - Calandaring | 1 | April 7th 06 04:48 PM |