Thread
:
Importing Tasks from Access on startup
View Single Post
#
2
February 16th 06, 04:40 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
Posts: 11,651
Importing Tasks from Access on startup
You can use the MAPIFolder.Items.Find method to look for an item that matches your specific criteria. (You have to decide what constitutes a match. Have you thought about maintaining a unique ID in the Outlook tasks that match an ID in your Access table?) See
http://www.outlookcode.com/d/finddate.htm
for tips on searching on date fields.
You don't need to display and close the newly created items. Just use Save.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
"Grant Bush" Grant
wrote in message ...
I've got some vba code setup to import tasks from an access table upon
outlook starting, but I need to add code to compare the task items to make
sure that they aren't duplicated. Below is the code that I have. I would
appreciate any help offerred and if there is a better code that should be
used, let me know.
thanks.
Grant Bush
Private Sub Application_Startup(ByVal Item As Object, Cancel As Boolean)
Dim olns As Outlook.NameSpace
Dim oltaskfolder As Outlook.MAPIFolder
Dim oltaskitem As Outlook.TaskItem
Dim objConn As ADODB.Connection
Dim objrst As ADODB.Recordset
Dim objfld As ADODB.field
Dim strsql As String
Set olns = Application.GetNamespace("MAPI")
Set oltasksfolder = olns.GetDefaultFolder(olFolderTasks)
Set objConn = CreateObject("ADODB.Connection")
Set objrst = CreateObject("ADODB.Recordset")
strsql = "SELECT * From Gbdd;"
objConn.provider = "Microsoft.jet.oledb.4.0"
objConn.Open "I:\bush\rockford ehs.mdb"
objrst.Open strsql, objConn, adopenforwardonly, adlockoptimistic
objrst.movefirst
While Not objrst.EOF
Set oltaskitem = oltasksfolder.Items.Add("IPM.task")
oltaskitem.Display
oltaskitem.Subject = objrst.Fields("Description")
oltaskitem.DueDate = objrst.Fields("compliance due date")
oltaskitem.ReminderTime = objrst.Fields("reminder date")
' oltaskitem.Notes = objrst.Fields("plant affected")
' oltaskitem.Status = objrst.Fields("status")
objrst.movenext
oltaskitem.Close olSave
Wend
objrst.Close
objConn.Close
Set objrst = Nothing
Set objConn = Nothing
Set olctitem = Nothing
Set objprospectfolder = Nothing
Set objctfolder = Nothing
Set objns = Nothing
End Sub
Sue Mosher [MVP-Outlook]
View Public Profile
View message headers
Find all posts by Sue Mosher [MVP-Outlook]
Find all threads started by Sue Mosher [MVP-Outlook]
Ads