Creating an email with the list of tasks

Status
Not open for further replies.

Barmoley

New Member
Outlook version
Outlook 2010 64 bit
Email Account
POP3
The below code is creating an email with the list of tasks, the only issue i that each row is starting with task category.
Please your kind help to modify the code , so I can see the task category and below it the tasks.



Public Sub CreatingReportFromTasks()
Dim objTask As Outlook.TaskItem
Dim objTaskFolder As Outlook.MAPIFolder
Dim objTaskItems As Outlook.Items
Dim objNS As Outlook.NameSpace

Set objNS = Application.GetNamespace("MAPI")
Set objTaskFolder = objNS.GetDefaultFolder(olFolderTasks)
Set objTaskItems = objTaskFolder.Items

Dim strBody As String

MyCategory = ""
strBody = ""
strCategory = ""

For Each objTask In objTaskItems
If objTask.Status <> olTaskComplete And (objTask.Categories = "1" Or objTask.Categories = "2" Or objTask.Categories = "3" Or objTask.Categories = "4") Then
If objTask.Categories <> MyCategory Then
MyCategory = objTask.Categories
End If
strBody = strBody & " " & MyCategory & ":" & objTask.Subject & vbNewLine ' & strbody
End If
Next

Dim objMsg As MailItem
Set objMsg = Application.CreateItem(olMailItem)
With objMsg
.To = ""
.Body = strBody
'.Display

End With
Debug.Print strBody

Set objTask = Nothing
Set objTaskItems = Nothing
Set objTaskFolder = Nothing
Set objNS = Nothing
Set objMsg = Nothing
End Sub
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
M Outlook 2007 Contacts Glitch: Creating a new email Using Outlook 1
S Creating Email - Selecting Pre-Defined Text Using Outlook 2
M creating email from contact file = 3 emails in To field Using Outlook 3
A Creating an outlook rule to forward an email with a specific message Using Outlook 1
E Creating email templates for organizational use Using Outlook 0
B Need Help Creating Email Based on Subject w Address in Body Outlook VBA and Custom Forms 1
L Creating a Task from Email and Attaching Original Email Outlook VBA and Custom Forms 6
M Outlook 2010 and how to get attachments listed when creating a new email? Using Outlook 1
S When creating new email, i come to the "File pane". Using Outlook 1
R Way to correct the window in focus when creating a task from email? Using Outlook 1
R Creating a new contact and email address disappears after field change Using Outlook 1
R Creating input form within the body of an email Using Outlook 1
T Auto-complete when creating an email isn't working correctly. Using Outlook 1
K Outlook defaults to personal folder when creating new email account Using Outlook 4
M Saved email in .html format is creating a seperate folder, in addition to the file Using Outlook 3
A Help creating custom Contacts form - what type is 'Email' control? Outlook VBA and Custom Forms 1
Fozzie Bear Outlook 2016 Creating a shared local Contacts folder Using Outlook 2
R Creating a user defined function Outlook VBA and Custom Forms 3
M Creating an RSS Feed **FROM** Outlook 2013 Calendar. Using Outlook 5
O How to prevent CC from showing when creating a new mail? Using Outlook 1
N Creating a button or link to a form in the Organizational Forms Library Outlook VBA and Custom Forms 3
L Creating drafts when I thought I was sending Using Outlook 1
R Would creating a new profile cause Outlook to download all the old mails from the server? Using Outlook 1
A Creating Progress Bar or Status Bar Update Outlook VBA and Custom Forms 0
T Outlook creating a folder named: "Unwanted" Using Outlook 3
Liza Creating a rule in outlook to filter messages Using Outlook 0
A Are categories still recommended for creating local distribution lists? Using Outlook 3
D Creating an outlook session from Access vba but run silently. With A specific profile Outlook VBA and Custom Forms 1
M Creating Outlook Appointments from Excel Cells Outlook VBA and Custom Forms 1
N Creating New Profile Using Outlook 0
Y Creating custom appointment request form with multiple mail recipients Outlook VBA and Custom Forms 5
P Recover / Extract Rules from standalone PST file creating RWZ file Using Outlook 2
I Creating meeting invite with disabled tentative button Outlook VBA and Custom Forms 5
N Creating or changing the main new mail message template in Outlook 2010 Using Outlook 2
D Creating custom view with VBA Outlook VBA and Custom Forms 2
J Outlook creating unwanted rule on its own Using Outlook 1
R Creating a Room Mailbox with Exchange Online Outlook VBA and Custom Forms 0
A Creating a rule on “Deleted items” folder Using Outlook 1
CMG73 Creating templates with predefined subject and CC Using Outlook 1
G Creating Contact Sub Folders Using Outlook 2
Rupert Dragwater creating gmail account in Outlook 2013 Using Outlook 7
nathandavies Creating a Select Case for a directory of folders Outlook VBA and Custom Forms 1
2 creating custom stationery Using Outlook 2
A Help creating macro for conditional formatting settings Using Outlook 8
Fozzie Bear Creating Custom Meeting Form Outlook VBA and Custom Forms 6
U Creating a (This computer only) folder within an IMAP account directory Using Outlook 1
A Creating archive rule on the clients by script/ Outlook VBA and Custom Forms 3
J Creating a URL from a message body excerpt before forwarding Using Outlook 2
A Creating rule to create week folder and transfer mail using alert Using Outlook 3
J Creating an "isolated" shared calendar in Outlook Outlook VBA and Custom Forms 1
Similar threads


















































Top