Solved

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

Posted on 2009-06-29
4
296 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now