?
Solved

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

Posted on 2009-06-29
4
Medium Priority
?
302 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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

777 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