Sending Emails From MS Access

F

fiona.innes

Hiya,

What I require to do is have a email button on my frmDetails so that
when a user clicks on it it composes an email which sends to the email
address (e-mail address removed) from MS Outlook and have the text "New
Freight has been added to the warehouse with booking ref:" and it
then inserts the booking ref from the field strBookingRef on the
frmDetails. When the email is sent I would like the email button to
be disabled.

Any ideas

Fiona
 
D

Dennis

Put this code in the click event of your E-Mail button

DoCmd.SendObject acSendNoObject, , , "(e-mail address removed)", , , "Your
Subject Line", "New Freight has been added to the warehouse with booking ref:
" & strBookingRef, False

SomeOtherControlOnYourForm.SetFocus
EMailButton.Enabled = False
 
F

fiona.innes

Thanks the 1st bit works, where do you put

SomeOtherControlOnYourForm.SetFocus
EMailButton.Enabled = False


confused?

Fiona
 
D

Dennis

In the click event of your email button, straight after the DoCmd.SendObject
... line
The SomeOtherControlOnYourForm needs to be the name of a control on your
form because you cannot disable the button if it has the focus. It will have
the focus because you have just clicked it.
 
D

Dennis

Yes but you have to move the focus off it before it can be disabled. That is
what those 2 lines of code do. Move the focus in your access form to another
control other your your e-mail button, then diable the e-mail button.
 
S

Stockwell43

What Dennis is saying by setting the focus to another field is something if
you have a comments field on your form then use the code Dennis gave you to
look like this:

Me.Comments.SetFocus
EmailButton.Enabled = False

Or use your bookingref field

Me.Bookingref.SetFocus
EmailButton.Enabled=False



Provided the name of your Comments field is Comments
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top