Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Duplicate Outlook 2007 "New Task For Contact" Functionality In VBA

Posted on 2014-03-23
2
Medium Priority
?
420 Views
Last Modified: 2014-03-24
When a user right-clicks a Contact in Outlook 2007, then clicks "Create," they can click the option of "Create New Task For Contact" to create a new task for the Contact.  This is VERY convenient because in addition to creating the new Task, the Task is also automatically linked to the Contact (see bottom left corner of the new Task to the right of the "Contacts ..." button).

I need to create this functionality using VBA.  In addition to this functionality I also need to set the value for several of the new Task's fields using the same VBA code (e.g., Subject, Start Date, etc.).  I am an experienced Excel VBA user and I understand the object model fairly well.  Does anyone have any ideas how I might code this functionality?

Thanks,

Bill Vallance
0
Comment
Question by:bvallanc
2 Comments
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 39949863
Hi,

pls try

Sub Test()
Dim objOutlook As New Outlook.Application
Dim objTask As Outlook.TaskItem
Set objTask = objOutlook.Session.GetDefaultFolder(olFolderTasks).Items.Add

objTask.Recipients.Add "FirstName LastName"
objTask.ContactNames = "ContactName"
objTask.Subject = "Subj"
objTask.Body = "Test Body"
objTask.DueDate = Now() + 1
objTask.Assign
objTask.Send
objTask.Close olSave
End Sub

Open in new window

Regards
0
 

Author Closing Comment

by:bvallanc
ID: 39950815
Perfect!  Thanks Rgonzo1971 for the quick response.  This worked perfectly.

Bill Vallance
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
Mailbox Corruption is a nightmare every Exchange DBA wishes he never has. Recovering from it can be super-hectic if not entirely futile. And though techniques like the New-MailboxRepairRequest cmdlet have been designed to help with fixing minor corr…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question