send email from button on a form

jonnycattt

Registered User.
Local time
Today, 20:05
Joined
Sep 29, 2001
Messages
20
Greetings.
I'm new to forms and I need a quick piece of code.
I have a form that contains a bunch of data, among them is an email address. I'd like to put a button on a form that, when clicked, opens an outlook "send" box with the email address in question in the to: field.
I've put buttons on forms that send emails to static addresses, but I don't know how to get the code to take the email address from the current record.

Thanks for any help
 
Hello,

You can refer to the current record as following:
Code:
DoCmd.SendObject acSendNoObject, "Outlook Express", , Forms!formname!nameoftextbox

This should work.

Greetings,

Albert
 
Isn't it easier to make your email field a hyperlink and click on this to open outlook rather than writing code for a command button to do this?

I found that was easier for me but it really depends on if you want to do it this way.
 
This will do it for you:

DoCmd.SendObject , , , Me.Email, , , Me.Subject, "TextToSend", True

This assumes that the Email and subject are going to be pulled from the form. Just rename the Me.Email and Me.Subject to match your controls name. You could also do the same thing with the "TextToSend" field. If you change the true at the end to a false the email will automaticaly be sent without a promt from the sender.

There is a lot of different arguments that you can use to send email, if you have further questions or would like more help be specific with what you want to do including the relevant field/control names.


____________________________________________________________

The ever increasingly inaccurately named UBB Board List for PC Support.
____________________________________________________________
 
WOW we all posted at the same time, well almost randrop3 beat us by 1 minute. Hayley, as far as Hyperlinks go, I have heard of a lot of people having trouble with them in many instances.

____________________________________________________________

The ever increasingly inaccurately named UBB Board List for PC Support.
____________________________________________________________
 
Yeah will I did too to begin with but works fine now. I know there are other better ways but for now I am sticking to what I know until I learn that bit more.

Thanks
 
OK, thanks for your help so far.

It's almost working. it pulls the right data from the fields, but when the email box opens, the cursor remains an hour glass....the whole thing just hangs.

Here's my code (Email and LogicID are names of fields on the form):

DoCmd.SendObject acSendNoObject, , , Email, , , LogicID, "insert text here", True

I tried it both with the acSendNoObject and without it. the behavior was the same.

Any ideas?

Marc
 
Try it like this:

DoCmd.SendObject , , , Me.Email, , , Me.LogicID, "insert text here", True

That should work for you.
 
I tried what you suggested, but it's still hanging.

here's my code:

DoCmd.SendObject , , , FEB_2002_Form.Email, , , FEB_2002_Form.LogicID, "insert text here", True

FEB_2002_Form is the form name, and Email and LogicID are the field names, respectively. Is this the correct naming convention for form controls?
 
Hello,

I used this code:

DoCmd.SendObject , , , Forms!FEB_2002_Form!email, , , Forms!FEB_2002_Form!logicID, "insert text here", True

and first it was also hanging, but after 10 seconds (20?) it worked fine. After the first time trying to send an email, my computer did nog hang anymore. Just click and send, click and send. (Oke, the first time I just pressed ctrl+alt+del, but I did NOT exit the proces. I just returned to Access by clicking on cancel and then it worked!)

Hope you can do something with this.

Albert

[This message has been edited by raindrop3 (edited 01-08-2002).]
 
Thanks all.
It's still hanging. I can type and use the keyboard to switch between fields, and I can use ctrl enter to send the email, so it's workable for me. Annoying (because i can't figure it out!), but workable.

Thanks for all your help.

Marc
 
Can you strip the database of any personal/private data, zip it up and send it to me? At least then you can figure out wether it is code or machine specific.

As far as your code goes I am a little surprised that is works at all without using the form object colection or by rederencing the object like this Me.[ControlName]
 
OK all: it works.

I guess I should've posted the entire command. See I was using the Mouse UP event, not the click event. When I changed it to the click event, it quit hanging.

thanks for all your help!
 

Users who are viewing this thread

Back
Top Bottom