• Subject: AccessXP to Outlook2007 issue
  • Author: bobh
  • Date: 21 Jan 2010
  • References:
Hi,

I'm hoping someone can help me understand what is going on with the
following senario. I have posted this in the Access forum but have not
recieved any replies so I thought I would try here.


I have AccessXP with Outlook2007 and this vba code on a form in
Access which sends an email, with Outlook 'closed' this code works as
long
as I attach a file.
If I comment out the .Attachedment Add line with Outlook closed the
code fails on the .Send line with error -> 287 - Application-defined
or Object-defined Error


But, with Outlook open this code works with or without
the .Attachment Add line.


I don't get it, why do I have to have an attachment in order to get
this code to work with Outlook closed???
bobh.


Dim objOutlook As Object, objMail As Object
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)


With objMail
.To = TheTo
.Subject = TheSubj
.body = TheBody
.Attachments.Add "c:\empty.txt"
.Importance = olImportanceHigh
.ReadReceiptRequested = True
.Send
End With
'clean up
Set objMail = Nothing
Set objOutlook = Nothing
21 Jan 2010AccessXP to Outlook2007 issue.bobh
Contact Us
All times are in (US) Eastern Daylight Time (GMT -4:00)