Susan Harkins
ssharkins at gmail.com
Mon Nov 12 16:34:13 CST 2007
I think I've figured it out, although I haven't tried it -- I'm going to have to create an Outlook Application and NameSpace object, via a MAPI folder. I didn't think it'd be this much work, but it is Outlook... Susan H. I posted the following code on the tech list this weekend, but so far haven't resolved the problem I'm having. I'm trying to send Access values to Outlook as a new contact. The Set itm = itms.Add("IPM.Contact") statement returns a can't set object variable error. Susan H. Function SendContactsToOutlook() Dim rst As New ADODB.Recordset Dim cnn As New ADODB.Connection '--------- 'Must set reference to Outlook library '--------- Dim itms As Outlook.Items Dim itm As Outlook.ContactItem Set cnn = CurrentProject.Connection rst.Open "tblContacts", cnn 'Outlook Folder name is hardcoded Set itm = itms.Add("IPM.Contact") With itm .CustomerID = Nz(rst!CustomerID) .FirstName = Nz(rst!FirstName) .LastName = Nz(rst!LastName) .Department = Nz(rst!Department) .Birthday = Nz(rst!Department) .Close (olSave) 'DoCmd.RunCommand acCmdSaveRecord End With Set rst = Nothing Set cnn = Nothing Set itms = Nothing Set itm = Nothing End Function