Solved

How to use Senkeys in MS Access 2007 while computer is locked

Posted on 2009-06-29
4
298 Views
Last Modified: 2013-11-28
Hi.  I have an Access 2007 form which automatically at certain times sends a report in the body of the e-mail.  To have this automated, i have the outlook message displayed and then use SendKeys to Send "Alt S" to automatically send the e-mail.  Works fine while my computer is active, but i need this to occur while i'm not there as well.  Sendkeys will not work if the computer is locked.  I discovered this by coming in to work the next day after leaving it running to find 6 composed outlook messages on my desktop that did not send themselves.  Is there a way to use sendkeys while the computer is locked, or if not, is there an alternative method where the e-mails would send themselves while my computer is locked? Thanks.
0
Comment
Question by:liebs
[X]
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
  • 2
4 Comments
 
LVL 5

Expert Comment

by:rizwanidrees
ID: 24742622
You can use Send() Function of outlook object to do the same without sendkeys
0
 
LVL 5

Accepted Solution

by:
rizwanidrees earned 500 total points
ID: 24742646
  Dim Outlook As Object, OutlookMail As Object, Attachment As Object
   Set Outlook = CreateObject("Outlook.Application")
   Set OutlookMail = Outlook.CreateItem(0)
   Set Attachment = OutlookMail.Attachments
   OutlookMail.To = strTo
   OutlookMail.CC = strCC
   OutlookMail.BCC = strBCC
   OutlookMail.Subject = strSubject
   OutlookMail.Body = strBody
   Attachment.Add strAtt, 1, 1, "File Attachment"

Option - A
   'OutlookMail.Send

Option - B
   OutlookMail.Display
   SendKeys "%{s}", True
0
 
LVL 84
ID: 24743947
And SendKeys is notoriously unreliable. SendKeys will attempt to work on whatever is the "current" application, which can changes in a split second, depending on what's happening on the machine outside of Access. Do yourself a favor and use Option A that rizwanidrees suggests.
0
 

Author Closing Comment

by:liebs
ID: 31598229
This worked perfectly! Thank you so much for your help!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
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…

763 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