Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating outlook tasks within access

Status
Not open for further replies.

monnet

IS-IT--Management
Feb 5, 2007
9
US
Hello everyone,


I’m looking to create a VB code within access to open a new task assignment within outlook. I want it to populate the task body text section with items from an access query (similar to a Mail merge in word). For each line of the query I would like a new task to be created. After this is completed i would like it to send the task assignment to a person within my office. I know i will need outlook objects installed but other than that i am a little lost.

If this command line is too complex to write or simply impossible to crate, is there a third party software that could automate this?

Thanks everyone.
 
You can easily add a reference to Outlook. Just go to modules, open any module, and open the references dialogue box (from the drop down menu: Tools > References). Then navigate to msoutl.olb (it's normally in C:\Program Files\Microsoft Office\OFFICE11, but do a search just in case). Strictly speaking, this isn't necessary since you can code a reference to an Outlook application like this:

Dim appOutlook As Object

Set appOutlook = CreateObject("Outlook.Application")

However, if you do set a reference to the Outlook Library you'll be able to use the Object Browser (press F2) to look at the application properties and objects.

The following creates a TaskItem and a MailItem with the TaskItem as an attachment:

Dim appOutlook As Object
Dim objMailItem As Object
Dim objTaskItem As Object

Set appOutlook = CreateObject("Outlook.Application")
Set objTaskItem = appOutlook.CreateItem(3) 'olTaskItem = 3
With objTaskItem
.StartDate = Now()
.Subject = "Trial"
.Body = "Trial"
.Save
End With
Set objMailItem = appOutlook.CreateItem(0) 'olMailItem = 0
With objMailItem
.To = <<e-mail address>>
.Attachments.Add objTaskItem, 1 'olByValue = 1
.Display
End With
Set appOutlook = Nothing

You could loop through your recordset creating TaskItems with .Body = Recordset.Fields(FieldName) and attach them to an email.

However, if you try and send these e-mails automatically you'll get the dreaded SR2 prompt "Another application is trying to open Outlook" etc...

For other ideas on Outlook programming try this site:
I hope this will point you in the right direction.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top