Solved

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

Posted on 2009-06-29
4
300 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 85
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

690 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