472,107 Members | 1,395 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,107 software developers and data experts.

Sending Email and the lovely SendKeys command.

I would like to send email automatically via a command button. I have
accomplished this just fine through the following code: (Outlook
should already be open for reliable results)

Private Sub Command6_Click()
ReturnValue = Shell("Outlook.EXE", 1) ' Run Outlook
SendKeys "%(F)", True
SendKeys "W", True
SendKeys "M", True 'Open New Message
SendKeys "ra*********@harbornet.com", True '<-- Email Address
SendKeys "{TAB 2}", True
SendKeys "TestSubject", True '<-- Subject Line
SendKeys "{TAB}", True
SendKeys "Test Message", True '<-- Message Text
SendKeys "%(s)", True 'Send Message
End Sub

I have gone a little overkill with the sendkeys command (VB newbie).
Can any of you guru's step into my code so that it will place the
value of a text box rather than the values I have submited via
sendkeys for the email address, subjectline, and message text.

Your help is greatly appreciated.

Regards,
Jeremy
Nov 12 '05 #1
6 11912
Mr. Bungle wrote:
I would like to send email automatically via a command button. I have
accomplished this just fine through the following code: (Outlook
should already be open for reliable results)

Private Sub Command6_Click()
ReturnValue = Shell("Outlook.EXE", 1) ' Run Outlook
SendKeys "%(F)", True
SendKeys "W", True
SendKeys "M", True 'Open New Message
SendKeys "ra*********@harbornet.com", True '<-- Email Address
SendKeys "{TAB 2}", True
SendKeys "TestSubject", True '<-- Subject Line
SendKeys "{TAB}", True
SendKeys "Test Message", True '<-- Message Text
SendKeys "%(s)", True 'Send Message
End Sub

I have gone a little overkill with the sendkeys command (VB newbie).
Can any of you guru's step into my code so that it will place the
value of a text box rather than the values I have submited via
sendkeys for the email address, subjectline, and message text.

Your help is greatly appreciated.

Regards,
Jeremy

Consider DoCmd.SendObject or
Application.FollowHyperLink "mailto:adress@domain?subject=wibble&body=text "
--
Error reading sig - A)bort R)etry I)nfluence with large hammer
Nov 12 '05 #2
Mr. Bungle wrote:
I would like to send email automatically via a command button. I have
accomplished this just fine through the following code: (Outlook
should already be open for reliable results)

Private Sub Command6_Click()
ReturnValue = Shell("Outlook.EXE", 1) ' Run Outlook
SendKeys "%(F)", True
SendKeys "W", True
SendKeys "M", True 'Open New Message
SendKeys "ra*********@harbornet.com", True '<-- Email Address
SendKeys "{TAB 2}", True
SendKeys "TestSubject", True '<-- Subject Line
SendKeys "{TAB}", True
SendKeys "Test Message", True '<-- Message Text
SendKeys "%(s)", True 'Send Message
End Sub

I have gone a little overkill with the sendkeys command (VB newbie).
Can any of you guru's step into my code so that it will place the
value of a text box rather than the values I have submited via
sendkeys for the email address, subjectline, and message text.

Your help is greatly appreciated.

Regards,
Jeremy

Consider DoCmd.SendObject or
Application.FollowHyperLink "mailto:adress@domain?subject=wibble&body=text "
--
Error reading sig - A)bort R)etry I)nfluence with large hammer
Nov 12 '05 #3
Trevor Best <nospam@localhost> wrote in message news:<40***********************@auth.uk.news.easyn et.net>...
Mr. Bungle wrote:
I would like to send email automatically via a command button. I have
accomplished this just fine through the following code: (Outlook
should already be open for reliable results)

Private Sub Command6_Click()
ReturnValue = Shell("Outlook.EXE", 1) ' Run Outlook
SendKeys "%(F)", True
SendKeys "W", True
SendKeys "M", True 'Open New Message
SendKeys "ra*********@harbornet.com", True '<-- Email Address
SendKeys "{TAB 2}", True
SendKeys "TestSubject", True '<-- Subject Line
SendKeys "{TAB}", True
SendKeys "Test Message", True '<-- Message Text
SendKeys "%(s)", True 'Send Message
End Sub

I have gone a little overkill with the sendkeys command (VB newbie).
Can any of you guru's step into my code so that it will place the
value of a text box rather than the values I have submited via
sendkeys for the email address, subjectline, and message text.

Your help is greatly appreciated.

Regards,
Jeremy

Consider DoCmd.SendObject or
Application.FollowHyperLink "mailto:adress@domain?subject=wibble&body=text "


2 questions about this...

Using the Application.FollowHyperlink can you bind the email address,
subject, and body to a control on your form?

The DoCmd.SendObject command works wonders at home where I developed
it, it automatically sends email exactly how I want it. However, to my
demise,at work the function does absolutly nothing. We use an exchange
server at work (which is where I want to use this). Might this
(exchange server) have something to do with why the DoCmd.SendObject
does not work?

The Application.FollowHyperlink alternative approach works fine at my
work, the only problem as notated above is that I would like to bind
the email, subject, and body to a control on the form. Any
suggestions?

Regards,
Jeremy

Thanks,
Jeremy
Nov 12 '05 #4
Trevor Best <nospam@localhost> wrote in message news:<40***********************@auth.uk.news.easyn et.net>...
Mr. Bungle wrote:
I would like to send email automatically via a command button. I have
accomplished this just fine through the following code: (Outlook
should already be open for reliable results)

Private Sub Command6_Click()
ReturnValue = Shell("Outlook.EXE", 1) ' Run Outlook
SendKeys "%(F)", True
SendKeys "W", True
SendKeys "M", True 'Open New Message
SendKeys "ra*********@harbornet.com", True '<-- Email Address
SendKeys "{TAB 2}", True
SendKeys "TestSubject", True '<-- Subject Line
SendKeys "{TAB}", True
SendKeys "Test Message", True '<-- Message Text
SendKeys "%(s)", True 'Send Message
End Sub

I have gone a little overkill with the sendkeys command (VB newbie).
Can any of you guru's step into my code so that it will place the
value of a text box rather than the values I have submited via
sendkeys for the email address, subjectline, and message text.

Your help is greatly appreciated.

Regards,
Jeremy

Consider DoCmd.SendObject or
Application.FollowHyperLink "mailto:adress@domain?subject=wibble&body=text "


2 questions about this...

Using the Application.FollowHyperlink can you bind the email address,
subject, and body to a control on your form?

The DoCmd.SendObject command works wonders at home where I developed
it, it automatically sends email exactly how I want it. However, to my
demise,at work the function does absolutly nothing. We use an exchange
server at work (which is where I want to use this). Might this
(exchange server) have something to do with why the DoCmd.SendObject
does not work?

The Application.FollowHyperlink alternative approach works fine at my
work, the only problem as notated above is that I would like to bind
the email, subject, and body to a control on the form. Any
suggestions?

Regards,
Jeremy

Thanks,
Jeremy
Nov 12 '05 #5
sl********@hotmail.com (Mr. Bungle) wrote:
I would like to send email automatically via a command button.


See the Access Email FAQ at my website.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Nov 12 '05 #6
Mr. Bungle wrote:
Trevor Best <nospam@localhost> wrote in message news:<40***********************@auth.uk.news.easyn et.net>...
Consider DoCmd.SendObject or
Application.FollowHyperLink "mailto:adress@domain?subject=wibble&body=text "

2 questions about this...

Using the Application.FollowHyperlink can you bind the email address,
subject, and body to a control on your form?

The DoCmd.SendObject command works wonders at home where I developed
it, it automatically sends email exactly how I want it. However, to my
demise,at work the function does absolutly nothing. We use an exchange
server at work (which is where I want to use this). Might this
(exchange server) have something to do with why the DoCmd.SendObject
does not work?


No, SendObject uss your mail client, it doesn't give a hoot what your
mail server software is.
The Application.FollowHyperlink alternative approach works fine at my
work, the only problem as notated above is that I would like to bind
the email, subject, and body to a control on the form. Any
suggestions?


(assumed textbox names)

Application.FollowHyperLink "mailto:" & txtAddress & "?subject=" &
txtSubject & "&body=" & txtBody

--
Error reading sig - A)bort R)etry I)nfluence with large hammer
Nov 12 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by StuartD | last post: by
reply views Thread by federico | last post: by
reply views Thread by Mac via DotNetMonster.com | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.