I have created code in Acc2003 that runs fine. The code takes a string which is an email address and opens Outlook 2003 and inserts the email address in the To: Field.
When this code tries to send the email address to Outlook 2007 I get this error message:
Error 287 'Application-defined or Object-defined error'. I know EXACTLY the line of code that generates this error. See code below.
I tried to run the code out of Acc2007 with Outlook 2007. SAME result. It makes no diference whether I use Acc2003 or Acc2007, the problem comes when the destination is Outlook2007.
Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
On Error GoTo Err_SendMessage:
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim dbs As Database
Set dbs = CurrentDb
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(strEmailTo) THIS LINE CAUSES THE ERROR
objOutlookRecip.Type = olTo