+ Reply to Thread
Results 1 to 4 of 4

Sending e-mail - Alternative to SendKeys and Wait?

  1. #1
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Question Sending e-mail - Alternative to SendKeys and Wait?

    I am trying to get Excel 2003 to send e-mails using Outlook 2003.

    Currently I have the following code, which works, but I'd like to improve if possible;

    Please Login or Register  to view this content.
    So it 'builds' the emails no problem, (once the user has clicked on the Outlook "A program is trying to aceess addresses" security box that I haven't found a way around ).
    Then I discovered that I had to '.Display' the emails, as using '.Send' incurs a 5 second delay thanks to an Outlook Security warning, which then needs the [Yes] button clicking.

    What I do now is display the message, wait one second, then use SendKeys to do Alt-S to send the e-mail. This may (or may not) cause the Spell checker to open (if check before sending has been selected in Outlook), so then I have to wait again, and then send the 'escape' key to close the spell checker, then wait another second, before then sending keys again to 'click' the [Yes] - Send the email even though the spell checker was closed before it was complete.

    Like I said, it works, but I don't have a huge faith in its stability and I'm intrigued to know if there is another way around this.

    Thanks
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Sending e-mail - Alternative to SendKeys and Wait?

    Adding recipients isn't necessary.
    And this code suffices:

    Please Login or Register  to view this content.



  3. #3
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Sending e-mail - Alternative to SendKeys and Wait?

    Thanks for the information about the recipients, that will save some complexity and code lines.

    However the ".Send" at the end still gives the same behaviour, and hence I still may have to use sendkeys.
    It presents the "A program is trying to send e-mail on your behalf, do you wish to allow this" security box. There is then a 5 second delay before the [Yes] button is enabled, which takes me back to having to use Application.Wait to 'hang' Excel for 5+ seconds, then use SendKeys to 'click' the [Yes] button.

    As I need to send quite a large number of emails waiting for 5 seconds between each one is not a workable solution. I found the only way around that was to .Display instead of .Send, but then you still have to use SendKeys to 'click' the [Send] button, and then all the other gumph for avoiding the spell checker as in my original post

    Any other ideas?

    Thanks

  4. #4
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Sending e-mail - Alternative to SendKeys and Wait?

    Anyone any ideas?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1