View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default 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" wrote in message
news:1hb6qbn.4yh2ee135hg5dN%grbridgeREMOVETHIS@bti nternet.com...
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").Col umns("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