Results 1 to 10 of 10
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,097

    How to close email client following a DoCmd.SendObject

    From a Task Scheduled to run in the middle of the night.......................

    I have a section of code that sends out an email, all of which works perfectly, except for some reason the Thunderbird email client remains open after the Send completes. As you can see, the post editing option in the DoCmd.SendObject statement is set to "False", so there's no user interaction with the email before it is sent.

    Code:
    DoCmd.SendObject acSendNoObject, , , strToList, , , strEMSubj, strEMBody, False
    It will be much appreciated if some kind soul would share a few lines of code that tests if Thunderbird is open and if so to close it?

    Thanks,


    Bill

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Hey Bill!

    Untried, but perhaps:

    http://theaccessweb.com/api/api0025.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    alborg is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2022
    Location
    Virginia, USA
    Posts
    11
    Why do you have to test if it's open? Just close the darn thing...

    The way that I have done this with other open programs is to make an applet, and name it "closeThunderbird.bat". After you run your sendobject code, just call up the "closeThunderbird.bat" afterwards.

    To make the "closeThunderbird.bat" you open Notepad and put in this DOS code:

    taskkill /im thunderbird.EXE /t /f

    Save and close it, then after your sendobject line, run:

    ShellEx "c:\yourfoldername\closeThunderbird.bat"

    I haven't tested this specifically since I don't use Thunderbird, but it should work whether Thunderbird is open or not.

    I used this code to try to kill Dragon Naturally Speaking, but it would only close about 4 of the 7 processes (DNS makes MS Access run incredibly slow with all the processes in memory). In my office I would also use this process to kill MS Access (taskkill /im MSACCESS.EXE /t /f) in other front end computers at a scheduled time so as to be able to close down any active software front ends before upgrading their systems.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    I was thinking along tha same lines, but with vbscript which I have used in the past to kill certain processes.
    As you know it is one task, then taskkill seems the sweetest option.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,097
    Thanks Alborg,
    Shell worked just fine. Apparently ShellEx requires a reference missing from my DB, I looked for it among the Reference menu but didn't see a candidate.
    Thanks again,
    Bill

    EDIT: Need a timer for a minute or so before I close Thunderbird or the SendObject becomes effectively a NOPT.

  6. #6
    alborg is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2022
    Location
    Virginia, USA
    Posts
    11
    Hi Bill-
    Using the sendobject method, don't you get a popup of your email after every sendoff? It's Microsoft's way to prevent spam email sendoffs.

    I ran into this when I retired last year. I needed to send off about 3049 records in one batch. I found the work-around, that I could bypass this this per-sendoff popup by sending the emails directly to Outlook (making outlook an application object). I sent all 3049 records, each with my retirement letter and with an attachment (a summary of their particular chart), in 27 minutes. If you need the code, I could post it for you

    Regards,
    Al.

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,097
    Thanks for the thought. In my case, with the "acSendNoObject" option of SendObject, the only email content is essentially the Subject and Body. The last argument is false so as to suppress user editing of the email body subsequent to the send action. With that, none of the object volume is an issue. Beware though Gmail's number of recipients when you have a case like mine, as Gmail has a fit if more than 99 recipients are included in the To+CC+BCC count.
    Code:
    DoCmd.SendObject acSendNoObject, , , strToList, , , strEMSubj, strEMBody, False
    (PS) Retired 30 years ago and continue to screw with this stuff from time-to-time.

  8. #8
    alborg is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2022
    Location
    Virginia, USA
    Posts
    11
    You don't get the following pop up with the sendobject set to false?

    Click image for larger version. 

Name:	popupwith0.png 
Views:	12 
Size:	71.7 KB 
ID:	51915

    Each email sent off in that manner had only one recipient (since it had his/her information). The 27 minutes was the time it took for Access to cycle through the complete table, attaching different chart summaries with each sendoff. The AI letter had appropriate areas automatically changed (s.a. Dear Mr. Doe...).

    I tell you, retirement is great! Working with Access is one of my favorite past times.

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I do a lot of emailing, that popup was solved for me by method 1:

    https://learn.microsoft.com/en-us/ou...on-your-behalf
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,097
    I seem to recall that I got the usual security alert from Thunderbird the first and only time my task sent an email. It's similar to the first time one uses a gmail SMTP server authorization to send out email from Access, at least with a third party client like Thunderbird.

    I'm glad to hear you're enjoying your retirement. You'll find the Access Forum is attended by some of the most knowledgeable and helpful folks. Some, like PBaldy, are VIP's but all-in-all you'll find those that reply to questions bring forth useful help. Ignore the snarky overtones that might come with a reply and garner the help offered and reply with appropriate grace.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 07-25-2014, 07:53 AM
  2. Replies: 10
    Last Post: 03-26-2012, 08:17 PM
  3. VBA Send Email using DoCmd.SendObject
    By malamute20 in forum Programming
    Replies: 15
    Last Post: 10-05-2011, 12:44 PM
  4. Replies: 1
    Last Post: 11-17-2010, 11:24 AM
  5. Email sent via DoCmd.SendObject
    By silverback in forum Programming
    Replies: 0
    Last Post: 10-29-2009, 06:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums