Solved

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

Posted on 2014-03-23
2
405 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 49

Accepted Solution

by:
Rgonzo1971 earned 500 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
If you don't know how to downgrade, my instructions below should be helpful.
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…
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now