SendObject to fill out addressee

mad-q

Registered User.
Local time
Today, 00:42
Joined
Feb 14, 2010
Messages
61
I have a form which has a field which has an e-mail address in and would like the Sendobject to take the e-mail address in that field and put it in the to line when the e-mail opens. I thought it would be as straight forward as Form![Customer]! in the TO box within the macro but, it doesn't like it. I can't find any answers anywhere.

Thanking you in advance.

Iain
 
Hi Iain

try

=

with [email] being the control source of the textbox from your form.


Kind regards
manc
 
Last edited:
Thank you for that, the problem I found when I do this is that it comes up with "Access can't find name 'email' you entered in the expression" I am putting = in the macro to argument. If I drop the = sign it happily works and tries to send an email to [email]

Hope can I get it to call the correct argument?

Thanks
Iain
 
I am presuming that your control source on the textbox containing the email address is 'email'. If it isn't, then change the =, to =[what ever your control source is that stores the email].

You could also name the textbox on your form to txtEmail for example, and reference that =[txtEmail].

Other than the above examples, that's where my knowledge ends I am afraid.

Good luck though
Kind regards
manc
 
Oops, macro not VBA. Sorry.

here is the code in VBA. Maybe someone can change it to a Macro for you.

Code:
Dim EmailAddress, Subject, MessageText
    
    'EmailAddress = "my@mail.com"
    EmailAddress = Email 'Where Email is the field
    Subject = "Subject line goes here"
    MessageText = "Line 1 of the email body" & vbNewLine & _
                  "Line 2 of the body" & vbNewLine & _
                  "Line 3 of the body" & vbNewLine & _
                  "Line 4 of the boddy"

    On Error Resume Next
    DoCmd.SendObject , , , EmailAddress, , , Subject, MessageText, True

Note that after SendObject, the first blank is for the type of object to send.
Leave it blank and its just an email
acSendForm = Send a Form.
acSendModule = Send a Module.
acSendNoObject = (Default) Don't send a database object.
acSendQuery = Send a Query.
acSendReport = Send a Report.
acSendTable = Send a Table.

The second blank is for the name of the object if you choose to send one

After EmailAddress you have To, CC and BCC

At the end is True (you can use a template thereafter). This can be left out as True is default. This basically leaves the email open for the user to add to it. False closes the email immediatly.
 
Last edited:
I have a form which has a field which has an e-mail address in and would like the Sendobject to take the e-mail address in that field and put it in the to line when the e-mail opens. I thought it would be as straight forward as Form![Customer]! in the TO box within the macro but, it doesn't like it. I can't find any answers anywhere.

Thanking you in advance.

Iain[/QUOTE]This because you wrote it incorrectly. It should be:

[Form[COLOR=Red][B]s[/B][/COLOR]]![Customer]![email]

Notice the [COLOR=Red]red [B]s[/B][/COLOR].
 

Users who are viewing this thread

Back
Top Bottom