+ Reply to Thread
Results 1 to 6 of 6

SendKeys problem

  1. #1
    Gordon Rainsford
    Guest

    SendKeys problem

    I have the following code, based on that at Ron de Bruin's site, which
    creates emails exactly as required, except that the SendKeys line does
    nothing. I've tried some variations of syntax, and it doesn't give an
    errormessage, but it just doesn't send. Does anyone have a suggestion as
    to what I'm doing wrong, or an alternative way of getting Outlook
    Express to send?

    Sub SendEmail()
    DatabaseOpen
    Set template = Workbooks("sendEmail.xls").Sheets("Sheet1")
    For Each Cell In
    Workbooks("ycDatabase.xls").Sheets("Database").Columns("M").Cells.Specia
    lCells(xlCellTypeConstants)
    If Cell.Value Like "*@*" Then
    Recipient = Cell.Value
    Subj = template.Range("c3").Value
    msg = "Dear " & Cell.Offset(0, -10).Value & "%0A"
    msg = msg & "%0A" & template.Range("c5").Value
    HLink = "mailto:" & Recipient & "?"
    HLink = HLink & "subject=" & Subj & "&"
    HLink = HLink & "body=" & msg
    ActiveWorkbook.FollowHyperlink (HLink)
    Application.Wait (Now + TimeValue("0:00:02"))
    Application.SendKeys "%S", True
    End If
    Next
    End Sub

    --
    Gordon Rainsford

    London UK

  2. #2
    RB Smissaert
    Guest

    Re: SendKeys problem

    Does Outlook Express have the focus?
    Maybe press the button with the API.
    I think that would be the PostMessage API.

    RBS

    "Gordon Rainsford" <[email protected]> wrote in message
    news:1hb6qbn.4yh2ee135hg5dN%[email protected]...
    >I have the following code, based on that at Ron de Bruin's site, which
    > creates emails exactly as required, except that the SendKeys line does
    > nothing. I've tried some variations of syntax, and it doesn't give an
    > errormessage, but it just doesn't send. Does anyone have a suggestion as
    > to what I'm doing wrong, or an alternative way of getting Outlook
    > Express to send?
    >
    > Sub SendEmail()
    > DatabaseOpen
    > Set template = Workbooks("sendEmail.xls").Sheets("Sheet1")
    > For Each Cell In
    > Workbooks("ycDatabase.xls").Sheets("Database").Columns("M").Cells.Specia
    > lCells(xlCellTypeConstants)
    > If Cell.Value Like "*@*" Then
    > Recipient = Cell.Value
    > Subj = template.Range("c3").Value
    > msg = "Dear " & Cell.Offset(0, -10).Value & "%0A"
    > msg = msg & "%0A" & template.Range("c5").Value
    > HLink = "mailto:" & Recipient & "?"
    > HLink = HLink & "subject=" & Subj & "&"
    > HLink = HLink & "body=" & msg
    > ActiveWorkbook.FollowHyperlink (HLink)
    > Application.Wait (Now + TimeValue("0:00:02"))
    > Application.SendKeys "%S", True
    > End If
    > Next
    > End Sub
    >
    > --
    > Gordon Rainsford
    >
    > London UK



  3. #3
    Gordon Rainsford
    Guest

    Re: SendKeys problem

    RB Smissaert <[email protected]> wrote:

    > Does Outlook Express have the focus?
    > Maybe press the button with the API.
    > I think that would be the PostMessage API.


    Could you explain a bit more?

    Thanks.


    --
    Gordon Rainsford

    London UK

  4. #4
    RB Smissaert
    Guest

    Re: SendKeys problem

    First one is easy:
    When you do your SendKeys does Outlook Express have the focus, that is does
    it take keyboard input?

    Second isn't that easy if you are not familiar with the API.
    You will need the window handle of that button and then send the message to
    it.
    Maybe have a go or ask in this newsgroup: microsoft.public.vb.winapi

    Another option is use Outlook and not Outlook Express as Outlook can be
    automated with VBA.

    RBS


    "Gordon Rainsford" <[email protected]> wrote in message
    news:1hb6sei.1aq5xgp9oryufN%[email protected]...
    > RB Smissaert <[email protected]> wrote:
    >
    >> Does Outlook Express have the focus?
    >> Maybe press the button with the API.
    >> I think that would be the PostMessage API.

    >
    > Could you explain a bit more?
    >
    > Thanks.
    >
    >
    > --
    > Gordon Rainsford
    >
    > London UK



  5. #5
    Ron de Bruin
    Guest

    Re: SendKeys problem

    Hi Gordon

    SendKeys is not always reliable
    Do you use Outlook or Outlook Express ?

    I like CDO for this
    http://www.rondebruin.nl/cdo.htm

    See
    http://www.rondebruin.nl/cdo.htm#message



    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "Gordon Rainsford" <[email protected]> wrote in message
    news:1hb6qbn.4yh2ee135hg5dN%[email protected]...
    >I have the following code, based on that at Ron de Bruin's site, which
    > creates emails exactly as required, except that the SendKeys line does
    > nothing. I've tried some variations of syntax, and it doesn't give an
    > errormessage, but it just doesn't send. Does anyone have a suggestion as
    > to what I'm doing wrong, or an alternative way of getting Outlook
    > Express to send?
    >
    > Sub SendEmail()
    > DatabaseOpen
    > Set template = Workbooks("sendEmail.xls").Sheets("Sheet1")
    > For Each Cell In
    > Workbooks("ycDatabase.xls").Sheets("Database").Columns("M").Cells.Specia
    > lCells(xlCellTypeConstants)
    > If Cell.Value Like "*@*" Then
    > Recipient = Cell.Value
    > Subj = template.Range("c3").Value
    > msg = "Dear " & Cell.Offset(0, -10).Value & "%0A"
    > msg = msg & "%0A" & template.Range("c5").Value
    > HLink = "mailto:" & Recipient & "?"
    > HLink = HLink & "subject=" & Subj & "&"
    > HLink = HLink & "body=" & msg
    > ActiveWorkbook.FollowHyperlink (HLink)
    > Application.Wait (Now + TimeValue("0:00:02"))
    > Application.SendKeys "%S", True
    > End If
    > Next
    > End Sub
    >
    > --
    > Gordon Rainsford
    >
    > London UK




  6. #6
    Gordon Rainsford
    Guest

    Re: SendKeys problem

    Ron de Bruin <[email protected]> wrote:

    > Hi Gordon
    >
    > SendKeys is not always reliable
    > Do you use Outlook or Outlook Express ?


    Outlook Express
    >
    > I like CDO for this
    > http://www.rondebruin.nl/cdo.htm
    >
    > See
    > http://www.rondebruin.nl/cdo.htm#message


    That solved it - thanks Ron.


    --
    Gordon Rainsford

    London UK

+ 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