Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / February 2006

Tip: Looking for answers? Try searching our database.

SendKeys problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gordon Rainsford - 22 Feb 2006 23:57 GMT
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

Signature

Gordon Rainsford

London UK

RB Smissaert - 23 Feb 2006 00:12 GMT
Does Outlook Express have the focus?
Maybe press the button with the API.
I think that would be the PostMessage API.

RBS

>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
[quoted text clipped - 23 lines]
>    Next
> End Sub
Gordon Rainsford - 23 Feb 2006 00:38 GMT
> 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.

Signature

Gordon Rainsford

London UK

RB Smissaert - 23 Feb 2006 13:29 GMT
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

>> Does Outlook Express have the focus?
>> Maybe press the button with the API.
[quoted text clipped - 3 lines]
>
> Thanks.
Ron de Bruin - 23 Feb 2006 20:35 GMT
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

Signature

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

>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
[quoted text clipped - 23 lines]
>    Next
> End Sub
Gordon Rainsford - 25 Feb 2006 08:56 GMT
> 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.

Signature

Gordon Rainsford

London UK

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.