Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Sending emails from Access - Error 287

Posted on 2014-03-11
7
2,817 Views
Last Modified: 2014-03-20
I'm trying to send an email from Access using Outlook.  I have several macros that send emails for different purposes, most using the docmd.sendobject method.  This works fine althought a security message does pop up in Outlook askingthe user to confirm the action, which is not a problem.

I then have another macro that is used to send an email with a word document as an attachement.  All was fine when we were using XP and 2003 but having upgraded to Win 7 and Office 2010 this no longer works.  I have tried several different methods of sending this email but the jist of it is ...

Dim oLook As Object
Dim oMail As Object
Set oLook = CreateObject("Outlook.Application")
Set oMail = oLook.CreateItem(0)

With oMail
   .To = test@test.com
   .Body ="Hello World"
   .Subject = "hello"
   .Attachments.Add ("attachment.doc")
   .Send
End With

Open in new window


All the different codes I have tried vary arround the use of creating an Outlook object.  I can't use the SendObject method because it does not support attachments.

The error message that I get is...
Run-time error '287':
Application-defined or object-defined error.

I have done a lot of research on the net trying to find a solution which I have not been able to find.

One thing that does keep coming up is security within Outlook not allowing Access to send emails.  Outlook doesn't even come up with the message asking the user to confirm the issue.

Has anyone else come up against this and know of a solution, whether in Access or Outlook?

TIA.
0
Comment
Question by:jdc1944
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39920471
change this

  .Attachments.Add ("attachment.doc")

to include the full path to the document

  .Attachments.Add ("c:\foldername\attachment.doc")
0
 
LVL 27

Accepted Solution

by:
MacroShadow earned 500 total points
ID: 39920490
0
 
LVL 19

Expert Comment

by:regmigrant
ID: 39920505
This is generated either when security disallows all programmatic access or user says 'no' to the request.

Have you tried to either disable outlook security or sign your project/MDB with a certificate so it is trusted
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 2

Author Comment

by:jdc1944
ID: 39920732
@MacroShadow
I've just used a CDO example and got it to work, thanks.  The only issue with that is the sent email does not appear in the sent items.  We kind of need this for an audit trail.  Do you know if this is possible at all?

@regmigrant
Thanks, all the settings are locked but I will get IT to change them for me and see if that gets my old code working in case the CDO method doesn't allow messages to be shown in the sent items of outlook.
0
 
LVL 27

Expert Comment

by:MacroShadow
ID: 39921226
When you sent an email using cdo it won't show up in Outlook's sent items since you are interacting directly with the mail server, the sent items are a mail client function, in your case Outlook's.
0
 
LVL 19

Expert Comment

by:regmigrant
ID: 39921512
You could cc the local user and set a category as an audit trail using CDO - this might be easier than the security/signing option
0
 
LVL 2

Author Closing Comment

by:jdc1944
ID: 39942372
Thanks, now set everything up using CDO and using the CC opetion as an audit trail.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question