Sending email messages on click to the address specified in a fiel

A

Adam

Hello all,

I have created a button called 'Notify person' on a form. The purpose of
this button is to notify a member of staff when an entry into a table has
been made against his / her name.

I have attempted to do this as follows.

In the properties tab of my button, on the event tab, at the On click option
I have created a Macro.

I have selected the SendObject command.

I wish to send the email to the address of the person whose name features in
a field which I have created on my table, entitled 'email'. As such in the
'to' column of the action arguments (in the macro) I have entered

This however, does not work and I receive the message (unknown message
recipient, the message was not sent).

I guess I'm just not specifying the field properly, but essentially I want
to send the email to whatever address is specified in the 'to' column.

Many thanks in advance.

Adam
 
F

freakazeud

Hi,
do you have a control on the form where this action is being executed which
is bound to the email table field? If so then you need to reference it
correctly.
I would suggest you do not use macros...they are very limited and cannot
handle error handling (at least not yet). Within VBA you can similarly use
the Sendobject method and just reference the form control which holds the
email value e.g.:

Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "Your Subject"
strToWhom = Me.YourControl 'referencing the form control which holds the
email address
strMsgBody = "Your Body text goes here!"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

HTH
Good luck
 
A

Adam

Hi freakazeud and thanks for your response.

I think the answer is yes...On the control source entry for the data tab of
my email field properties, 'email' (no quotes) is specified.

What I want to do ultimately is have a combo box which has the email address
of different partner organizations. Selecting one and clicking the send email
button would send the message specified to the email address. Also, I was
hoping to not actually display the full address in the dropdown men but a
representation of it, so for example - nike = (e-mail address removed), adidas =
(e-mail address removed) etc...

However, I was hoping to first get my databse to read whatever was in the
email field and work things out from there.

I'm a bit wary of using visual basic as I've never used it before nor done
any programming - however, if you think it's the best way to go, I'll
certainly give it a go. Without using macros, could I achieve this in the
expression builder, do you think?

Thanks again for your kind help.

Adam

freakazeud said:
Hi,
do you have a control on the form where this action is being executed which
is bound to the email table field? If so then you need to reference it
correctly.
I would suggest you do not use macros...they are very limited and cannot
handle error handling (at least not yet). Within VBA you can similarly use
the Sendobject method and just reference the form control which holds the
email value e.g.:

Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "Your Subject"
strToWhom = Me.YourControl 'referencing the form control which holds the
email address
strMsgBody = "Your Body text goes here!"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

HTH
Good luck
--
Oli-S
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


Adam said:
Hello all,

I have created a button called 'Notify person' on a form. The purpose of
this button is to notify a member of staff when an entry into a table has
been made against his / her name.

I have attempted to do this as follows.

In the properties tab of my button, on the event tab, at the On click option
I have created a Macro.

I have selected the SendObject command.

I wish to send the email to the address of the person whose name features in
a field which I have created on my table, entitled 'email'. As such in the
'to' column of the action arguments (in the macro) I have entered

This however, does not work and I receive the message (unknown message
recipient, the message was not sent).

I guess I'm just not specifying the field properly, but essentially I want
to send the email to whatever address is specified in the 'to' column.

Many thanks in advance.

Adam
[/QUOTE][/QUOTE]
 
B

BruceM

You could have the person's name or whatever you like as the combo box
visible column, with the e-mail address as another column in the combo box
Row Source. Let's say you combo box row source consists of the following
fields from a Contacts table, in this order in the design grid: ContactID,
ContactName, ContactEmail. Set the combo box column count to 3, the bound
column to 1, and the column widths to 0";1.5";0" (use whatever width works
for the visible column. In the example previously given, set strToWhom as
follows:
strToWhom = Me.cboYourComboName.Column(2)
Use your actual combo box name, of course. Note that in VBA the column
count starts at 0, so Column(2) is actually the third column.
Don't be nervous about VBA. To enter a VBA procedure, open the property
sheet for the command button (View > Properties). Click the Event tab, and
click next to On Click. Click the three dots, click Code Builder, and click
OK. You will see something like:

Private Sub cmdNotify_Click()

End Sub

Place the code between those lines. There's a lot of potential complexity
to VBA coding, but the basic procedure for adding code need not intimidate
you. I don't think you could use an expression to send e-mail unless maybe
you managed to create a user-defined function, but if you're going to do
that you'll need VBA anyhow.

Adam said:
Hi freakazeud and thanks for your response.

I think the answer is yes...On the control source entry for the data tab
of
my email field properties, 'email' (no quotes) is specified.

What I want to do ultimately is have a combo box which has the email
address
of different partner organizations. Selecting one and clicking the send
email
button would send the message specified to the email address. Also, I was
hoping to not actually display the full address in the dropdown men but a
representation of it, so for example - nike = (e-mail address removed), adidas =
(e-mail address removed) etc...

However, I was hoping to first get my databse to read whatever was in the
email field and work things out from there.

I'm a bit wary of using visual basic as I've never used it before nor done
any programming - however, if you think it's the best way to go, I'll
certainly give it a go. Without using macros, could I achieve this in the
expression builder, do you think?

Thanks again for your kind help.

Adam

freakazeud said:
Hi,
do you have a control on the form where this action is being executed
which
is bound to the email table field? If so then you need to reference it
correctly.
I would suggest you do not use macros...they are very limited and cannot
handle error handling (at least not yet). Within VBA you can similarly
use
the Sendobject method and just reference the form control which holds the
email value e.g.:

Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "Your Subject"
strToWhom = Me.YourControl 'referencing the form control which holds the
email address
strMsgBody = "Your Body text goes here!"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

HTH
Good luck
--
Oli-S
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


Adam said:
Hello all,

I have created a button called 'Notify person' on a form. The purpose
of
this button is to notify a member of staff when an entry into a table
has
been made against his / her name.

I have attempted to do this as follows.

In the properties tab of my button, on the event tab, at the On click
option
I have created a Macro.

I have selected the SendObject command.

I wish to send the email to the address of the person whose name
features in
a field which I have created on my table, entitled 'email'. As such in
the
'to' column of the action arguments (in the macro) I have entered


This however, does not work and I receive the message (unknown message
recipient, the message was not sent).

I guess I'm just not specifying the field properly, but essentially I
want
to send the email to whatever address is specified in the 'to' column.

Many thanks in advance.

Adam
[/QUOTE][/QUOTE][/QUOTE]
 
F

freakazeud

Hi,
Forms/reports hold controls...fields are in tables, so you want to reference
a bound contorl which holds the value. It doesn't really matter what this
control is textbox/combo...the only difference is that refering to the
default value property of comboboxes will return the bound column value. If
the email is in that one then you are fine...if not then you need to
reference the correct column. The column count is zero based so refering to
the second column would be:

Me.YourCombo.Column(1)

So you can have the actual email in the second column and an alias in the
first column which is the only one displayed (specify the column width in the
combobox format properties).
To add the email code open your form in design view...open the button's
property dialog. Go to the event tab and browse for the on click event.
Select [event procedure] from the drop down list and click the "..." next to
it. This will open the VBA editor with a preformatted on click routine for
you. Add the SendObject code in between the beginning and end of the
procedure. In the 'To' argument of the sendobject code refernce the combobox
(either its default value property or some specific column) as somewhat
described earlier in the small sample. Close the editor...open form in form
view...select something in the combo...press the button and see what happens
:) You just have written your first custom VBA procedure.
HTH
Good luck
--
Oli-S
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


Adam said:
Hi freakazeud and thanks for your response.

I think the answer is yes...On the control source entry for the data tab of
my email field properties, 'email' (no quotes) is specified.

What I want to do ultimately is have a combo box which has the email address
of different partner organizations. Selecting one and clicking the send email
button would send the message specified to the email address. Also, I was
hoping to not actually display the full address in the dropdown men but a
representation of it, so for example - nike = (e-mail address removed), adidas =
(e-mail address removed) etc...

However, I was hoping to first get my databse to read whatever was in the
email field and work things out from there.

I'm a bit wary of using visual basic as I've never used it before nor done
any programming - however, if you think it's the best way to go, I'll
certainly give it a go. Without using macros, could I achieve this in the
expression builder, do you think?

Thanks again for your kind help.

Adam

freakazeud said:
Hi,
do you have a control on the form where this action is being executed which
is bound to the email table field? If so then you need to reference it
correctly.
I would suggest you do not use macros...they are very limited and cannot
handle error handling (at least not yet). Within VBA you can similarly use
the Sendobject method and just reference the form control which holds the
email value e.g.:

Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "Your Subject"
strToWhom = Me.YourControl 'referencing the form control which holds the
email address
strMsgBody = "Your Body text goes here!"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

HTH
Good luck
--
Oli-S
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


Adam said:
Hello all,

I have created a button called 'Notify person' on a form. The purpose of
this button is to notify a member of staff when an entry into a table has
been made against his / her name.

I have attempted to do this as follows.

In the properties tab of my button, on the event tab, at the On click option
I have created a Macro.

I have selected the SendObject command.

I wish to send the email to the address of the person whose name features in
a field which I have created on my table, entitled 'email'. As such in the
'to' column of the action arguments (in the macro) I have entered

This however, does not work and I receive the message (unknown message
recipient, the message was not sent).

I guess I'm just not specifying the field properly, but essentially I want
to send the email to whatever address is specified in the 'to' column.

Many thanks in advance.

Adam
[/QUOTE][/QUOTE][/QUOTE]
 
A

Adam

Thanks BruceM for the help with this.

I've followed what you suggested and I'm pretty sure the column side of
things is correct but I'm having problems with the VB code builder side of
things.

I seem to have messed things up a bit. When I opened the proprty tab of my
button I did not see:

Private Sub cmdNotify_Click()
End Sub

and I started to delete what was there and enter the code given to me in the
previous post... Realising this wasn't working I tried to create a new
button, but it seems that the deletions I made carried onto the next button?
In any event, the code which now appears at the tab for my button is:

"
Private Sub cmdNotify_Click()
Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "adamstest"
strToWhom = Me.cboContactEmail.Column(2)
strMsgBody = "adamstestcontent"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

End Sub

Private Sub Command113_Click()

End Sub

Private Sub Command114_Click()

End Sub "

'ContactEmail' is the label / caption name for the field entitled 'email'. I
tried replacing 'email' above but with no success.

Is it possible to undo the deletion of code I've carried out? I'm a bit lost
but hopefully on the righ track.

Again, many thanks for your help so far!

Cheers

Adam
BruceM said:
You could have the person's name or whatever you like as the combo box
visible column, with the e-mail address as another column in the combo box
Row Source. Let's say you combo box row source consists of the following
fields from a Contacts table, in this order in the design grid: ContactID,
ContactName, ContactEmail. Set the combo box column count to 3, the bound
column to 1, and the column widths to 0";1.5";0" (use whatever width works
for the visible column. In the example previously given, set strToWhom as
follows:
strToWhom = Me.cboYourComboName.Column(2)
Use your actual combo box name, of course. Note that in VBA the column
count starts at 0, so Column(2) is actually the third column.
Don't be nervous about VBA. To enter a VBA procedure, open the property
sheet for the command button (View > Properties). Click the Event tab, and
click next to On Click. Click the three dots, click Code Builder, and click
OK. You will see something like:

Private Sub cmdNotify_Click()

End Sub

Place the code between those lines. There's a lot of potential complexity
to VBA coding, but the basic procedure for adding code need not intimidate
you. I don't think you could use an expression to send e-mail unless maybe
you managed to create a user-defined function, but if you're going to do
that you'll need VBA anyhow.

Adam said:
Hi freakazeud and thanks for your response.

I think the answer is yes...On the control source entry for the data tab
of
my email field properties, 'email' (no quotes) is specified.

What I want to do ultimately is have a combo box which has the email
address
of different partner organizations. Selecting one and clicking the send
email
button would send the message specified to the email address. Also, I was
hoping to not actually display the full address in the dropdown men but a
representation of it, so for example - nike = (e-mail address removed), adidas =
(e-mail address removed) etc...

However, I was hoping to first get my databse to read whatever was in the
email field and work things out from there.

I'm a bit wary of using visual basic as I've never used it before nor done
any programming - however, if you think it's the best way to go, I'll
certainly give it a go. Without using macros, could I achieve this in the
expression builder, do you think?

Thanks again for your kind help.

Adam

freakazeud said:
Hi,
do you have a control on the form where this action is being executed
which
is bound to the email table field? If so then you need to reference it
correctly.
I would suggest you do not use macros...they are very limited and cannot
handle error handling (at least not yet). Within VBA you can similarly
use
the Sendobject method and just reference the form control which holds the
email value e.g.:

Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "Your Subject"
strToWhom = Me.YourControl 'referencing the form control which holds the
email address
strMsgBody = "Your Body text goes here!"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

HTH
Good luck
--
Oli-S
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Hello all,

I have created a button called 'Notify person' on a form. The purpose
of
this button is to notify a member of staff when an entry into a table
has
been made against his / her name.

I have attempted to do this as follows.

In the properties tab of my button, on the event tab, at the On click
option
I have created a Macro.

I have selected the SendObject command.

I wish to send the email to the address of the person whose name
features in
a field which I have created on my table, entitled 'email'. As such in
the
'to' column of the action arguments (in the macro) I have entered


This however, does not work and I receive the message (unknown message
recipient, the message was not sent).

I guess I'm just not specifying the field properly, but essentially I
want
to send the email to whatever address is specified in the 'to' column.

Many thanks in advance.

Adam
[/QUOTE][/QUOTE]
[/QUOTE]
 
A

Adam

Hello freakazeud
Really appreciate the effort you and BruceM are putting in.

Unfortunately, however, I have not yet cracked it....

I deleted my old buttons and have created a new button with only the
following code:

Private Sub cmdNotify_Click()
Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "adamstest"
strToWhom = Me.email.Column(2)
strMsgBody = "adamstestcontent"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

End Sub

My comboSource has a Data Control Source entitled 'email'. I created three
columns in my table with those values and the email address is in the 3rd one
(i.e. Column2).

I have saved this and selected my email, pressed the button...and nothing
happens....

I tried also changing 'email' to the Name of the contact email combo box but
this didn't seem to work either. I feel I am pretty close thanks to your help
but just can't quite get it....

Cheers,

Adam


freakazeud said:
Hi,
Forms/reports hold controls...fields are in tables, so you want to reference
a bound contorl which holds the value. It doesn't really matter what this
control is textbox/combo...the only difference is that refering to the
default value property of comboboxes will return the bound column value. If
the email is in that one then you are fine...if not then you need to
reference the correct column. The column count is zero based so refering to
the second column would be:

Me.YourCombo.Column(1)

So you can have the actual email in the second column and an alias in the
first column which is the only one displayed (specify the column width in the
combobox format properties).
To add the email code open your form in design view...open the button's
property dialog. Go to the event tab and browse for the on click event.
Select [event procedure] from the drop down list and click the "..." next to
it. This will open the VBA editor with a preformatted on click routine for
you. Add the SendObject code in between the beginning and end of the
procedure. In the 'To' argument of the sendobject code refernce the combobox
(either its default value property or some specific column) as somewhat
described earlier in the small sample. Close the editor...open form in form
view...select something in the combo...press the button and see what happens
:) You just have written your first custom VBA procedure.
HTH
Good luck
--
Oli-S
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


Adam said:
Hi freakazeud and thanks for your response.

I think the answer is yes...On the control source entry for the data tab of
my email field properties, 'email' (no quotes) is specified.

What I want to do ultimately is have a combo box which has the email address
of different partner organizations. Selecting one and clicking the send email
button would send the message specified to the email address. Also, I was
hoping to not actually display the full address in the dropdown men but a
representation of it, so for example - nike = (e-mail address removed), adidas =
(e-mail address removed) etc...

However, I was hoping to first get my databse to read whatever was in the
email field and work things out from there.

I'm a bit wary of using visual basic as I've never used it before nor done
any programming - however, if you think it's the best way to go, I'll
certainly give it a go. Without using macros, could I achieve this in the
expression builder, do you think?

Thanks again for your kind help.

Adam

freakazeud said:
Hi,
do you have a control on the form where this action is being executed which
is bound to the email table field? If so then you need to reference it
correctly.
I would suggest you do not use macros...they are very limited and cannot
handle error handling (at least not yet). Within VBA you can similarly use
the Sendobject method and just reference the form control which holds the
email value e.g.:

Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "Your Subject"
strToWhom = Me.YourControl 'referencing the form control which holds the
email address
strMsgBody = "Your Body text goes here!"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

HTH
Good luck
--
Oli-S
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Hello all,

I have created a button called 'Notify person' on a form. The purpose of
this button is to notify a member of staff when an entry into a table has
been made against his / her name.

I have attempted to do this as follows.

In the properties tab of my button, on the event tab, at the On click option
I have created a Macro.

I have selected the SendObject command.

I wish to send the email to the address of the person whose name features in
a field which I have created on my table, entitled 'email'. As such in the
'to' column of the action arguments (in the macro) I have entered

This however, does not work and I receive the message (unknown message
recipient, the message was not sent).

I guess I'm just not specifying the field properly, but essentially I want
to send the email to whatever address is specified in the 'to' column.

Many thanks in advance.

Adam
[/QUOTE][/QUOTE][/QUOTE]
 
B

BruceM

You need to specify how the combo box will get the rows you see when you
click the down arrow. This is the combo box Row Source. It is different
from the Control Source. A combo box, like a text box (or chekc box, label,
and everything else on a form) is called a control. A control is bound if
it is linked to a field in the form's underlying table. That is the
control's Control Source. If you need to save the information you select
from a combo box, you need to bind the combo box to a Control Source by
selecting the name of the field. In order to do this the form itself needs
to be bound to a record source such as a table or query.
Some forms don't need to be bound to a Record Source (search forms, for
instance), and not every control needs to be bound to a field. It depends
on the situation.
Anyhow, you need to specify the combo box Row Source. When you click the
three buttons as described you will see a query design grid. You can select
the table you need, then select the fields you need, as I think I already
described. Again, the details depend on your situation. When you are done,
click View > Datasheet to see if you are getting the expected results. If
so, close the query, and click OK when prompted about updating the property.
Now you can enter the code as described for the command button. Do not
over-complicate it. Create a command button. Go into its properties and
name it cmdNotify or whatever you wish (it's good to leave spaces out of it,
and to use only letters, numbers, and underscores). Now go to the Event tab
and proceed as described with the Click event.
If you are not getting the expected results for the row source, post
details. One step at a time here; once the combo box is working, feel free
to post more questions. If you can't get it to work, be as specific as
possible about what you have tried.

Adam said:
Hello freakazeud
Really appreciate the effort you and BruceM are putting in.

Unfortunately, however, I have not yet cracked it....

I deleted my old buttons and have created a new button with only the
following code:

Private Sub cmdNotify_Click()
Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "adamstest"
strToWhom = Me.email.Column(2)
strMsgBody = "adamstestcontent"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

End Sub

My comboSource has a Data Control Source entitled 'email'. I created three
columns in my table with those values and the email address is in the 3rd
one
(i.e. Column2).

I have saved this and selected my email, pressed the button...and nothing
happens....

I tried also changing 'email' to the Name of the contact email combo box
but
this didn't seem to work either. I feel I am pretty close thanks to your
help
but just can't quite get it....

Cheers,

Adam


freakazeud said:
Hi,
Forms/reports hold controls...fields are in tables, so you want to
reference
a bound contorl which holds the value. It doesn't really matter what this
control is textbox/combo...the only difference is that refering to the
default value property of comboboxes will return the bound column value.
If
the email is in that one then you are fine...if not then you need to
reference the correct column. The column count is zero based so refering
to
the second column would be:

Me.YourCombo.Column(1)

So you can have the actual email in the second column and an alias in the
first column which is the only one displayed (specify the column width in
the
combobox format properties).
To add the email code open your form in design view...open the button's
property dialog. Go to the event tab and browse for the on click event.
Select [event procedure] from the drop down list and click the "..." next
to
it. This will open the VBA editor with a preformatted on click routine
for
you. Add the SendObject code in between the beginning and end of the
procedure. In the 'To' argument of the sendobject code refernce the
combobox
(either its default value property or some specific column) as somewhat
described earlier in the small sample. Close the editor...open form in
form
view...select something in the combo...press the button and see what
happens
:) You just have written your first custom VBA procedure.
HTH
Good luck
--
Oli-S
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


Adam said:
Hi freakazeud and thanks for your response.

I think the answer is yes...On the control source entry for the data
tab of
my email field properties, 'email' (no quotes) is specified.

What I want to do ultimately is have a combo box which has the email
address
of different partner organizations. Selecting one and clicking the send
email
button would send the message specified to the email address. Also, I
was
hoping to not actually display the full address in the dropdown men but
a
representation of it, so for example - nike = (e-mail address removed),
adidas =
(e-mail address removed) etc...

However, I was hoping to first get my databse to read whatever was in
the
email field and work things out from there.

I'm a bit wary of using visual basic as I've never used it before nor
done
any programming - however, if you think it's the best way to go, I'll
certainly give it a go. Without using macros, could I achieve this in
the
expression builder, do you think?

Thanks again for your kind help.

Adam

:

Hi,
do you have a control on the form where this action is being executed
which
is bound to the email table field? If so then you need to reference
it
correctly.
I would suggest you do not use macros...they are very limited and
cannot
handle error handling (at least not yet). Within VBA you can
similarly use
the Sendobject method and just reference the form control which holds
the
email value e.g.:

Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "Your Subject"
strToWhom = Me.YourControl 'referencing the form control which holds
the
email address
strMsgBody = "Your Body text goes here!"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

HTH
Good luck
--
Oli-S
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Hello all,

I have created a button called 'Notify person' on a form. The
purpose of
this button is to notify a member of staff when an entry into a
table has
been made against his / her name.

I have attempted to do this as follows.

In the properties tab of my button, on the event tab, at the On
click option
I have created a Macro.

I have selected the SendObject command.

I wish to send the email to the address of the person whose name
features in
a field which I have created on my table, entitled 'email'. As such
in the
'to' column of the action arguments (in the macro) I have entered


This however, does not work and I receive the message (unknown
message
recipient, the message was not sent).

I guess I'm just not specifying the field properly, but essentially
I want
to send the email to whatever address is specified in the 'to'
column.

Many thanks in advance.

Adam
[/QUOTE][/QUOTE][/QUOTE]
 
A

Adam

Good morning Bruce,

What you and Freakazeud posted makes sense and I've tried to follow it but I
seem to be going wrong somewhere....

As such I'll now post exactly the steps I have been taking and perhaps we
can identify where I have been going wrong. Apologies if it's something
simple.....

Step 1. - Setting up a table with Contact ID, Contact name and Contact email
from which to draw values for my drop down menu later.

1. I created a table called Contacts with the following fields:
emailID - Autonumber and key fields
emailname - text
emailaddress - text

2. I populated the table with 2 entries (autonumber, name and email address)

Step 2. - Create a Combotext Box using the Combo Box Wizard

1. I carried out the following steps:

Open the combo box wizard
Select 'I want the combo box to look up the values in a table or query.'
(next)
Select 'Contacts' table (next)
Select (bring to the right) fields emailID, emailname and email address.(next)
DO NOT SPECIFY ANY ORDER(next)
Adjust width of emailaddress column until it is zero and does not show. Key
value (emailID) is not showing. Only emailname column and content is
visible.(next)
Select 'Remember the value for later use'. (it is not required that this
email address is recorded on any table)(next)
Label the combo box 'emailname'(finish)

Step 3. - Creating a Simple Button

1. I did the following:

Deselect the wizard function and insert a button onto the form.
Righth click on the button and open its property box.

Click on 'Other' tab. Change name of button to 'sendemail'
Click on 'Format' tab. Change name of Caption to 'sendemail'
Click on 'Data' tab. Press '...' to the left of the on click row. Choose
code builder to open up the VB coding box.

In between the existing:

Private Sub sendemail_Click()

End Sub

Paste the following code:

Private Sub sendemail_Click()
Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "Your Subject"
strToWhom = Me.emailname.Column(2)
strMsgBody = "Your Body text goes here!"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True
End Sub

I save the code and then save the form.

I select the adam (with associated but non visible email column) entry from
the drop down menu and click the button.

I receive the following error:

'Compile Error - method or data member not found' and the emailname is
highlighted in code. From this I assume I have used the wrong name for my
combo box so I replace 'emailname' with 'Combo98'. (Combo98 is the name of
the combobox - automatically assigned) The new line of code is:

strToWhom = Me.Combo98.Column(2)

I save the code and form, test it and receive the following error:

Runtime error '2293'
Microsoft Office can't send this email message

I click Debug and the following line is highlighted:

'DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True'

Wow...a long post but I just wanted to make it really clear what I was
doing. I'm most concerend that I'm not using the code properly or have named
something incorrectly.

Again, many thanks for your help and assistance with this issue.

Adam




BruceM said:
You need to specify how the combo box will get the rows you see when you
click the down arrow. This is the combo box Row Source. It is different
from the Control Source. A combo box, like a text box (or chekc box, label,
and everything else on a form) is called a control. A control is bound if
it is linked to a field in the form's underlying table. That is the
control's Control Source. If you need to save the information you select
from a combo box, you need to bind the combo box to a Control Source by
selecting the name of the field. In order to do this the form itself needs
to be bound to a record source such as a table or query.
Some forms don't need to be bound to a Record Source (search forms, for
instance), and not every control needs to be bound to a field. It depends
on the situation.
Anyhow, you need to specify the combo box Row Source. When you click the
three buttons as described you will see a query design grid. You can select
the table you need, then select the fields you need, as I think I already
described. Again, the details depend on your situation. When you are done,
click View > Datasheet to see if you are getting the expected results. If
so, close the query, and click OK when prompted about updating the property.
Now you can enter the code as described for the command button. Do not
over-complicate it. Create a command button. Go into its properties and
name it cmdNotify or whatever you wish (it's good to leave spaces out of it,
and to use only letters, numbers, and underscores). Now go to the Event tab
and proceed as described with the Click event.
If you are not getting the expected results for the row source, post
details. One step at a time here; once the combo box is working, feel free
to post more questions. If you can't get it to work, be as specific as
possible about what you have tried.

Adam said:
Hello freakazeud
Really appreciate the effort you and BruceM are putting in.

Unfortunately, however, I have not yet cracked it....

I deleted my old buttons and have created a new button with only the
following code:

Private Sub cmdNotify_Click()
Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "adamstest"
strToWhom = Me.email.Column(2)
strMsgBody = "adamstestcontent"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

End Sub

My comboSource has a Data Control Source entitled 'email'. I created three
columns in my table with those values and the email address is in the 3rd
one
(i.e. Column2).

I have saved this and selected my email, pressed the button...and nothing
happens....

I tried also changing 'email' to the Name of the contact email combo box
but
this didn't seem to work either. I feel I am pretty close thanks to your
help
but just can't quite get it....

Cheers,

Adam


freakazeud said:
Hi,
Forms/reports hold controls...fields are in tables, so you want to
reference
a bound contorl which holds the value. It doesn't really matter what this
control is textbox/combo...the only difference is that refering to the
default value property of comboboxes will return the bound column value.
If
the email is in that one then you are fine...if not then you need to
reference the correct column. The column count is zero based so refering
to
the second column would be:

Me.YourCombo.Column(1)

So you can have the actual email in the second column and an alias in the
first column which is the only one displayed (specify the column width in
the
combobox format properties).
To add the email code open your form in design view...open the button's
property dialog. Go to the event tab and browse for the on click event.
Select [event procedure] from the drop down list and click the "..." next
to
it. This will open the VBA editor with a preformatted on click routine
for
you. Add the SendObject code in between the beginning and end of the
procedure. In the 'To' argument of the sendobject code refernce the
combobox
(either its default value property or some specific column) as somewhat
described earlier in the small sample. Close the editor...open form in
form
view...select something in the combo...press the button and see what
happens
:) You just have written your first custom VBA procedure.
HTH
Good luck
--
Oli-S
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Hi freakazeud and thanks for your response.

I think the answer is yes...On the control source entry for the data
tab of
my email field properties, 'email' (no quotes) is specified.

What I want to do ultimately is have a combo box which has the email
address
of different partner organizations. Selecting one and clicking the send
email
button would send the message specified to the email address. Also, I
was
hoping to not actually display the full address in the dropdown men but
a
representation of it, so for example - nike = (e-mail address removed),
adidas =
(e-mail address removed) etc...

However, I was hoping to first get my databse to read whatever was in
the
email field and work things out from there.

I'm a bit wary of using visual basic as I've never used it before nor
done
any programming - however, if you think it's the best way to go, I'll
certainly give it a go. Without using macros, could I achieve this in
the
expression builder, do you think?

Thanks again for your kind help.

Adam

:

Hi,
do you have a control on the form where this action is being executed
which
is bound to the email table field? If so then you need to reference
it
correctly.
I would suggest you do not use macros...they are very limited and
cannot
handle error handling (at least not yet). Within VBA you can
similarly use
the Sendobject method and just reference the form control which holds
the
email value e.g.:

Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "Your Subject"
strToWhom = Me.YourControl 'referencing the form control which holds
the
email address
strMsgBody = "Your Body text goes here!"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

HTH
Good luck
--
Oli-S
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Hello all,

I have created a button called 'Notify person' on a form. The
purpose of
this button is to notify a member of staff when an entry into a
table has
been made against his / her name.

I have attempted to do this as follows.

In the properties tab of my button, on the event tab, at the On
click option
I have created a Macro.

I have selected the SendObject command.

I wish to send the email to the address of the person whose name
features in
a field which I have created on my table, entitled 'email'. As such
in the
'to' column of the action arguments (in the macro) I have entered


This however, does not work and I receive the message (unknown
message
recipient, the message was not sent).

I guess I'm just not specifying the field properly, but essentially
I want
to send the email to whatever address is specified in the 'to'
column.

Many thanks in advance.

Adam
[/QUOTE][/QUOTE]
[/QUOTE]
 
B

BruceM

When posting code it is sometimes helpful to use naming conventions for the
benefit of those who are trying to sort out what you have done. For
instance, cmdSendEmail will identify a command button, cboContactEmail will
identify a combo box, and so forth. From your perspective a naming
convention may help to assure unique names, which keep the code from getting
confused. More comments inline.

Adam said:
Good morning Bruce,

What you and Freakazeud posted makes sense and I've tried to follow it but
I
seem to be going wrong somewhere....

As such I'll now post exactly the steps I have been taking and perhaps we
can identify where I have been going wrong. Apologies if it's something
simple.....

Step 1. - Setting up a table with Contact ID, Contact name and Contact
email
from which to draw values for my drop down menu later.

Do you already have a Contacts table? If so, add the e-mail address field
to that table rather than creating a separate table. It's not quite clear
what you have done in this regard.
1. I created a table called Contacts with the following fields:
emailID - Autonumber and key fields
emailname - text
emailaddress - text

2. I populated the table with 2 entries (autonumber, name and email
address)

I assume this to mean you added emailname and emailaddress, and that the
autonumber took care of itself, so that you have three fields.
Step 2. - Create a Combotext Box using the Combo Box Wizard

1. I carried out the following steps:

Open the combo box wizard
Select 'I want the combo box to look up the values in a table or query.'
(next)
Select 'Contacts' table (next)
Select (bring to the right) fields emailID, emailname and email
address.(next)
DO NOT SPECIFY ANY ORDER(next)
Adjust width of emailaddress column until it is zero and does not show.
Key
value (emailID) is not showing. Only emailname column and content is
visible.(next)
Select 'Remember the value for later use'. (it is not required that this
email address is recorded on any table)(next)
Label the combo box 'emailname'(finish)

One reason I don't tend to use the wizard is that it won't let me choose a
name. When I do use the wizard I go back into the code and change the combo
box name to something that has some meaning to me.
Step 3. - Creating a Simple Button

1. I did the following:

Deselect the wizard function and insert a button onto the form.
Righth click on the button and open its property box.

Click on 'Other' tab. Change name of button to 'sendemail'
Click on 'Format' tab. Change name of Caption to 'sendemail'
Click on 'Data' tab. Press '...' to the left of the on click row. Choose
code builder to open up the VB coding box.

In between the existing:

Private Sub sendemail_Click()

End Sub

Paste the following code:

The Private Sub and End Sub lines need to appear once only.
Private Sub sendemail_Click()
Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "Your Subject"
strToWhom = Me.emailname.Column(2)
strMsgBody = "Your Body text goes here!"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True
End Sub

I save the code and then save the form.

I select the adam (with associated but non visible email column) entry
from
the drop down menu and click the button.

I receive the following error:

'Compile Error - method or data member not found' and the emailname is
highlighted in code. From this I assume I have used the wrong name for my
combo box so I replace 'emailname' with 'Combo98'. (Combo98 is the name of
the combobox - automatically assigned) The new line of code is:

strToWhom = Me.Combo98.Column(2)

That is the correct choice, assuming that an e-mail address appears in
Column(2). To check, open the combo box property sheet and click the three
dots next to Row Source (Data tab). A query design grid should appear.
Emailaddress needs to be the third column. I sometimes add message boxes to
test code:

MsgBox strToWhom

after the line: strToWhom = Me.Combo98.Column(2)
I save the code and form, test it and receive the following error:

Before exiting the VBA window, click Debug > Compile. Are there any compile
errors?
Runtime error '2293'
Microsoft Office can't send this email message

Others have had problems with this. A Google groups search will produce a
number of articles. This one may contain some information.
http://support.microsoft.com/?id=884998
I click Debug and the following line is highlighted:

'DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True'

True is assumed, so there is no need for it. Try changing the command to
just DoCmd.SendObject. Does a blank e-mail appear? If so, continue
troubleshooting by replacing strToWhom with your e-mail address:
DoCmd.SendObject , , , (e-mail address removed)
If that works, try adding the rest of the code, until you get it to where
the error recurs.

If it does not work, use your e-mail address and change True to False. I
know that's not what you want, but using it for a test message to yourself
will at least identify what's going on.
Be sure you have all of the latest updates to Windows and Office. What
e-mail program are you using?
Wow...a long post but I just wanted to make it really clear what I was
doing. I'm most concerend that I'm not using the code properly or have
named
something incorrectly.

Again, many thanks for your help and assistance with this issue.

Adam




BruceM said:
You need to specify how the combo box will get the rows you see when you
click the down arrow. This is the combo box Row Source. It is different
from the Control Source. A combo box, like a text box (or chekc box,
label,
and everything else on a form) is called a control. A control is bound
if
it is linked to a field in the form's underlying table. That is the
control's Control Source. If you need to save the information you select
from a combo box, you need to bind the combo box to a Control Source by
selecting the name of the field. In order to do this the form itself
needs
to be bound to a record source such as a table or query.
Some forms don't need to be bound to a Record Source (search forms, for
instance), and not every control needs to be bound to a field. It
depends
on the situation.
Anyhow, you need to specify the combo box Row Source. When you click the
three buttons as described you will see a query design grid. You can
select
the table you need, then select the fields you need, as I think I already
described. Again, the details depend on your situation. When you are
done,
click View > Datasheet to see if you are getting the expected results.
If
so, close the query, and click OK when prompted about updating the
property.
Now you can enter the code as described for the command button. Do not
over-complicate it. Create a command button. Go into its properties and
name it cmdNotify or whatever you wish (it's good to leave spaces out of
it,
and to use only letters, numbers, and underscores). Now go to the Event
tab
and proceed as described with the Click event.
If you are not getting the expected results for the row source, post
details. One step at a time here; once the combo box is working, feel
free
to post more questions. If you can't get it to work, be as specific as
possible about what you have tried.

Adam said:
Hello freakazeud
Really appreciate the effort you and BruceM are putting in.

Unfortunately, however, I have not yet cracked it....

I deleted my old buttons and have created a new button with only the
following code:

Private Sub cmdNotify_Click()
Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "adamstest"
strToWhom = Me.email.Column(2)
strMsgBody = "adamstestcontent"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

End Sub

My comboSource has a Data Control Source entitled 'email'. I created
three
columns in my table with those values and the email address is in the
3rd
one
(i.e. Column2).

I have saved this and selected my email, pressed the button...and
nothing
happens....

I tried also changing 'email' to the Name of the contact email combo
box
but
this didn't seem to work either. I feel I am pretty close thanks to
your
help
but just can't quite get it....

Cheers,

Adam


:

Hi,
Forms/reports hold controls...fields are in tables, so you want to
reference
a bound contorl which holds the value. It doesn't really matter what
this
control is textbox/combo...the only difference is that refering to the
default value property of comboboxes will return the bound column
value.
If
the email is in that one then you are fine...if not then you need to
reference the correct column. The column count is zero based so
refering
to
the second column would be:

Me.YourCombo.Column(1)

So you can have the actual email in the second column and an alias in
the
first column which is the only one displayed (specify the column width
in
the
combobox format properties).
To add the email code open your form in design view...open the
button's
property dialog. Go to the event tab and browse for the on click
event.
Select [event procedure] from the drop down list and click the "..."
next
to
it. This will open the VBA editor with a preformatted on click routine
for
you. Add the SendObject code in between the beginning and end of the
procedure. In the 'To' argument of the sendobject code refernce the
combobox
(either its default value property or some specific column) as
somewhat
described earlier in the small sample. Close the editor...open form in
form
view...select something in the combo...press the button and see what
happens
:) You just have written your first custom VBA procedure.
HTH
Good luck
--
Oli-S
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Hi freakazeud and thanks for your response.

I think the answer is yes...On the control source entry for the data
tab of
my email field properties, 'email' (no quotes) is specified.

What I want to do ultimately is have a combo box which has the email
address
of different partner organizations. Selecting one and clicking the
send
email
button would send the message specified to the email address. Also,
I
was
hoping to not actually display the full address in the dropdown men
but
a
representation of it, so for example - nike = (e-mail address removed),
adidas =
(e-mail address removed) etc...

However, I was hoping to first get my databse to read whatever was
in
the
email field and work things out from there.

I'm a bit wary of using visual basic as I've never used it before
nor
done
any programming - however, if you think it's the best way to go,
I'll
certainly give it a go. Without using macros, could I achieve this
in
the
expression builder, do you think?

Thanks again for your kind help.

Adam

:

Hi,
do you have a control on the form where this action is being
executed
which
is bound to the email table field? If so then you need to
reference
it
correctly.
I would suggest you do not use macros...they are very limited and
cannot
handle error handling (at least not yet). Within VBA you can
similarly use
the Sendobject method and just reference the form control which
holds
the
email value e.g.:

Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "Your Subject"
strToWhom = Me.YourControl 'referencing the form control which
holds
the
email address
strMsgBody = "Your Body text goes here!"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

HTH
Good luck
--
Oli-S
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


:

Hello all,

I have created a button called 'Notify person' on a form. The
purpose of
this button is to notify a member of staff when an entry into a
table has
been made against his / her name.

I have attempted to do this as follows.

In the properties tab of my button, on the event tab, at the On
click option
I have created a Macro.

I have selected the SendObject command.

I wish to send the email to the address of the person whose name
features in
a field which I have created on my table, entitled 'email'. As
such
in the
'to' column of the action arguments (in the macro) I have
entered


This however, does not work and I receive the message (unknown
message
recipient, the message was not sent).

I guess I'm just not specifying the field properly, but
essentially
I want
to send the email to whatever address is specified in the 'to'
column.

Many thanks in advance.

Adam
[/QUOTE]
[/QUOTE][/QUOTE]
 
A

Adam

Hi BruceM,

Thanks again. First of all - addressing your previous coments:

'Do you already have a Contacts table? If so, add the e-mail address field
to that table rather than creating a separate table. It's not quite clear
what you have done in this regard'

- I created a new contacts table and populated it with the email names and
corresponding addreses of the people I wanted to appear on the drop down
list. The main exisitng table which I use for my forms has many more entries
than email contacts and I the email addresses which will appear in the combo
box won't relate to what's in the bigger (existing table) which is why I
created a new seperate small table.

'True is assumed, so there is no need for it. Try changing the command to
just DoCmd.SendObject.'

- I did this and still received the Runtime Error 2293 message.


I then added my email address inplace of the strToWhom but this time an
error was generated by the word assistant.

Working in an company office and I assume that they have all the latest
updates added (I can't install anything manually). Using Microsoft Outlook
2003

you directed me to http://support.microsoft.com/Default.aspx?id=884998

The prescribed workaround from here is the configue the outlook security
settings but I'm not sure that I'll be able / permitted to do this and in
any event, the access form from which emails would be sent would be used by
different users on different PCs (probably with their own settings).

I'm sort of at a loss now. I'll try starting a new form perhaps, and make
all the recommendations you made on the last post.

Very grateful for your assistance and I'll let you know if progress is made.

Adam


BruceM said:
When posting code it is sometimes helpful to use naming conventions for the
benefit of those who are trying to sort out what you have done. For
instance, cmdSendEmail will identify a command button, cboContactEmail will
identify a combo box, and so forth. From your perspective a naming
convention may help to assure unique names, which keep the code from getting
confused. More comments inline.

Adam said:
Good morning Bruce,

What you and Freakazeud posted makes sense and I've tried to follow it but
I
seem to be going wrong somewhere....

As such I'll now post exactly the steps I have been taking and perhaps we
can identify where I have been going wrong. Apologies if it's something
simple.....

Step 1. - Setting up a table with Contact ID, Contact name and Contact
email
from which to draw values for my drop down menu later.

Do you already have a Contacts table? If so, add the e-mail address field
to that table rather than creating a separate table. It's not quite clear
what you have done in this regard.
1. I created a table called Contacts with the following fields:
emailID - Autonumber and key fields
emailname - text
emailaddress - text

2. I populated the table with 2 entries (autonumber, name and email
address)

I assume this to mean you added emailname and emailaddress, and that the
autonumber took care of itself, so that you have three fields.
Step 2. - Create a Combotext Box using the Combo Box Wizard

1. I carried out the following steps:

Open the combo box wizard
Select 'I want the combo box to look up the values in a table or query.'
(next)
Select 'Contacts' table (next)
Select (bring to the right) fields emailID, emailname and email
address.(next)
DO NOT SPECIFY ANY ORDER(next)
Adjust width of emailaddress column until it is zero and does not show.
Key
value (emailID) is not showing. Only emailname column and content is
visible.(next)
Select 'Remember the value for later use'. (it is not required that this
email address is recorded on any table)(next)
Label the combo box 'emailname'(finish)

One reason I don't tend to use the wizard is that it won't let me choose a
name. When I do use the wizard I go back into the code and change the combo
box name to something that has some meaning to me.
Step 3. - Creating a Simple Button

1. I did the following:

Deselect the wizard function and insert a button onto the form.
Righth click on the button and open its property box.

Click on 'Other' tab. Change name of button to 'sendemail'
Click on 'Format' tab. Change name of Caption to 'sendemail'
Click on 'Data' tab. Press '...' to the left of the on click row. Choose
code builder to open up the VB coding box.

In between the existing:

Private Sub sendemail_Click()

End Sub

Paste the following code:

The Private Sub and End Sub lines need to appear once only.
Private Sub sendemail_Click()
Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "Your Subject"
strToWhom = Me.emailname.Column(2)
strMsgBody = "Your Body text goes here!"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True
End Sub

I save the code and then save the form.

I select the adam (with associated but non visible email column) entry
from
the drop down menu and click the button.

I receive the following error:

'Compile Error - method or data member not found' and the emailname is
highlighted in code. From this I assume I have used the wrong name for my
combo box so I replace 'emailname' with 'Combo98'. (Combo98 is the name of
the combobox - automatically assigned) The new line of code is:

strToWhom = Me.Combo98.Column(2)

That is the correct choice, assuming that an e-mail address appears in
Column(2). To check, open the combo box property sheet and click the three
dots next to Row Source (Data tab). A query design grid should appear.
Emailaddress needs to be the third column. I sometimes add message boxes to
test code:

MsgBox strToWhom

after the line: strToWhom = Me.Combo98.Column(2)
I save the code and form, test it and receive the following error:

Before exiting the VBA window, click Debug > Compile. Are there any compile
errors?
Runtime error '2293'
Microsoft Office can't send this email message

Others have had problems with this. A Google groups search will produce a
number of articles. This one may contain some information.
http://support.microsoft.com/?id=884998
I click Debug and the following line is highlighted:

'DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True'

True is assumed, so there is no need for it. Try changing the command to
just DoCmd.SendObject. Does a blank e-mail appear? If so, continue
troubleshooting by replacing strToWhom with your e-mail address:
DoCmd.SendObject , , , (e-mail address removed)
If that works, try adding the rest of the code, until you get it to where
the error recurs.

If it does not work, use your e-mail address and change True to False. I
know that's not what you want, but using it for a test message to yourself
will at least identify what's going on.
Be sure you have all of the latest updates to Windows and Office. What
e-mail program are you using?
Wow...a long post but I just wanted to make it really clear what I was
doing. I'm most concerend that I'm not using the code properly or have
named
something incorrectly.

Again, many thanks for your help and assistance with this issue.

Adam




BruceM said:
You need to specify how the combo box will get the rows you see when you
click the down arrow. This is the combo box Row Source. It is different
from the Control Source. A combo box, like a text box (or chekc box,
label,
and everything else on a form) is called a control. A control is bound
if
it is linked to a field in the form's underlying table. That is the
control's Control Source. If you need to save the information you select
from a combo box, you need to bind the combo box to a Control Source by
selecting the name of the field. In order to do this the form itself
needs
to be bound to a record source such as a table or query.
Some forms don't need to be bound to a Record Source (search forms, for
instance), and not every control needs to be bound to a field. It
depends
on the situation.
Anyhow, you need to specify the combo box Row Source. When you click the
three buttons as described you will see a query design grid. You can
select
the table you need, then select the fields you need, as I think I already
described. Again, the details depend on your situation. When you are
done,
click View > Datasheet to see if you are getting the expected results.
If
so, close the query, and click OK when prompted about updating the
property.
Now you can enter the code as described for the command button. Do not
over-complicate it. Create a command button. Go into its properties and
name it cmdNotify or whatever you wish (it's good to leave spaces out of
it,
and to use only letters, numbers, and underscores). Now go to the Event
tab
and proceed as described with the Click event.
If you are not getting the expected results for the row source, post
details. One step at a time here; once the combo box is working, feel
free
to post more questions. If you can't get it to work, be as specific as
possible about what you have tried.

Hello freakazeud
Really appreciate the effort you and BruceM are putting in.

Unfortunately, however, I have not yet cracked it....

I deleted my old buttons and have created a new button with only the
following code:

Private Sub cmdNotify_Click()
Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "adamstest"
strToWhom = Me.email.Column(2)
strMsgBody = "adamstestcontent"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

End Sub

My comboSource has a Data Control Source entitled 'email'. I created
three
columns in my table with those values and the email address is in the
3rd
one
(i.e. Column2).

I have saved this and selected my email, pressed the button...and
nothing
happens....

I tried also changing 'email' to the Name of the contact email combo
box
but
this didn't seem to work either. I feel I am pretty close thanks to
your
help
but just can't quite get it....

Cheers,

Adam


:

Hi,
Forms/reports hold controls...fields are in tables, so you want to
reference
a bound contorl which holds the value. It doesn't really matter what
this
control is textbox/combo...the only difference is that refering to the
default value property of comboboxes will return the bound column
value.
If
the email is in that one then you are fine...if not then you need to
reference the correct column. The column count is zero based so
refering
to
the second column would be:

Me.YourCombo.Column(1)

So you can have the actual email in the second column and an alias in
the
first column which is the only one displayed (specify the column width
in
the
combobox format properties).
To add the email code open your form in design view...open the
button's
property dialog. Go to the event tab and browse for the on click
event.
Select [event procedure] from the drop down list and click the "..."
next
to
it. This will open the VBA editor with a preformatted on click routine
for
you. Add the SendObject code in between the beginning and end of the
procedure. In the 'To' argument of the sendobject code refernce the
combobox
(either its default value property or some specific column) as
somewhat
described earlier in the small sample. Close the editor...open form in
form
view...select something in the combo...press the button and see what
happens
:) You just have written your first custom VBA procedure.
HTH
Good luck
--
 
B

BruceM

Here is another way of sending e-mails. It would be in the command button
Click event. I used to prefer this method with Access 2000 because
SendObject opened the e-mail in a very small window. Access 2003 seems to
have solved that problem. You could substitute fields, etc. as needed for
the Subject and Body strings.

Dim strEmail As String, strSubject As String, strBody As String
strSubject = "Subject test"
strBody = "Test message"
strEmail = "mailto:" & Me.Email & "?subject=" & strSubject & "&body=" &
strBody
Application.FollowHyperlink Address:=strEmail

I have no idea why mailto, subject, and body use different syntax from each
other. CC uses the same syntax as Body ("&CC="). I don't know what else is
possible with this method.

Having said this, SendObject should work, so I would encourage you to get to
the bottom of that. A new message thread identifying the error message
would probably get more response than a message buried in a thread.

Adam said:
Hi BruceM,

Thanks again. First of all - addressing your previous coments:

'Do you already have a Contacts table? If so, add the e-mail address field
to that table rather than creating a separate table. It's not quite clear
what you have done in this regard'

- I created a new contacts table and populated it with the email names and
corresponding addreses of the people I wanted to appear on the drop down
list. The main exisitng table which I use for my forms has many more
entries
than email contacts and I the email addresses which will appear in the
combo
box won't relate to what's in the bigger (existing table) which is why I
created a new seperate small table.

'True is assumed, so there is no need for it. Try changing the command to
just DoCmd.SendObject.'

- I did this and still received the Runtime Error 2293 message.


I then added my email address inplace of the strToWhom but this time an
error was generated by the word assistant.

Working in an company office and I assume that they have all the latest
updates added (I can't install anything manually). Using Microsoft Outlook
2003

you directed me to http://support.microsoft.com/Default.aspx?id=884998

The prescribed workaround from here is the configue the outlook security
settings but I'm not sure that I'll be able / permitted to do this and in
any event, the access form from which emails would be sent would be used
by
different users on different PCs (probably with their own settings).

I'm sort of at a loss now. I'll try starting a new form perhaps, and make
all the recommendations you made on the last post.

Very grateful for your assistance and I'll let you know if progress is
made.

Adam


BruceM said:
When posting code it is sometimes helpful to use naming conventions for
the
benefit of those who are trying to sort out what you have done. For
instance, cmdSendEmail will identify a command button, cboContactEmail
will
identify a combo box, and so forth. From your perspective a naming
convention may help to assure unique names, which keep the code from
getting
confused. More comments inline.

Adam said:
Good morning Bruce,

What you and Freakazeud posted makes sense and I've tried to follow it
but
I
seem to be going wrong somewhere....

As such I'll now post exactly the steps I have been taking and perhaps
we
can identify where I have been going wrong. Apologies if it's something
simple.....

Step 1. - Setting up a table with Contact ID, Contact name and Contact
email
from which to draw values for my drop down menu later.

Do you already have a Contacts table? If so, add the e-mail address
field
to that table rather than creating a separate table. It's not quite
clear
what you have done in this regard.
1. I created a table called Contacts with the following fields:
emailID - Autonumber and key fields
emailname - text
emailaddress - text

2. I populated the table with 2 entries (autonumber, name and email
address)

I assume this to mean you added emailname and emailaddress, and that the
autonumber took care of itself, so that you have three fields.
Step 2. - Create a Combotext Box using the Combo Box Wizard

1. I carried out the following steps:

Open the combo box wizard
Select 'I want the combo box to look up the values in a table or
query.'
(next)
Select 'Contacts' table (next)
Select (bring to the right) fields emailID, emailname and email
address.(next)
DO NOT SPECIFY ANY ORDER(next)
Adjust width of emailaddress column until it is zero and does not show.
Key
value (emailID) is not showing. Only emailname column and content is
visible.(next)
Select 'Remember the value for later use'. (it is not required that
this
email address is recorded on any table)(next)
Label the combo box 'emailname'(finish)

One reason I don't tend to use the wizard is that it won't let me choose
a
name. When I do use the wizard I go back into the code and change the
combo
box name to something that has some meaning to me.
Step 3. - Creating a Simple Button

1. I did the following:

Deselect the wizard function and insert a button onto the form.
Righth click on the button and open its property box.

Click on 'Other' tab. Change name of button to 'sendemail'
Click on 'Format' tab. Change name of Caption to 'sendemail'
Click on 'Data' tab. Press '...' to the left of the on click row.
Choose
code builder to open up the VB coding box.

In between the existing:

Private Sub sendemail_Click()

End Sub

Paste the following code:

The Private Sub and End Sub lines need to appear once only.
Private Sub sendemail_Click()
Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "Your Subject"
strToWhom = Me.emailname.Column(2)
strMsgBody = "Your Body text goes here!"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True
End Sub

I save the code and then save the form.

I select the adam (with associated but non visible email column) entry
from
the drop down menu and click the button.

I receive the following error:

'Compile Error - method or data member not found' and the emailname is
highlighted in code. From this I assume I have used the wrong name for
my
combo box so I replace 'emailname' with 'Combo98'. (Combo98 is the name
of
the combobox - automatically assigned) The new line of code is:

strToWhom = Me.Combo98.Column(2)

That is the correct choice, assuming that an e-mail address appears in
Column(2). To check, open the combo box property sheet and click the
three
dots next to Row Source (Data tab). A query design grid should appear.
Emailaddress needs to be the third column. I sometimes add message boxes
to
test code:

MsgBox strToWhom

after the line: strToWhom = Me.Combo98.Column(2)
I save the code and form, test it and receive the following error:

Before exiting the VBA window, click Debug > Compile. Are there any
compile
errors?
Runtime error '2293'
Microsoft Office can't send this email message

Others have had problems with this. A Google groups search will produce
a
number of articles. This one may contain some information.
http://support.microsoft.com/?id=884998
I click Debug and the following line is highlighted:

'DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True'

True is assumed, so there is no need for it. Try changing the command to
just DoCmd.SendObject. Does a blank e-mail appear? If so, continue
troubleshooting by replacing strToWhom with your e-mail address:
DoCmd.SendObject , , , (e-mail address removed)
If that works, try adding the rest of the code, until you get it to where
the error recurs.

If it does not work, use your e-mail address and change True to False. I
know that's not what you want, but using it for a test message to
yourself
will at least identify what's going on.
Be sure you have all of the latest updates to Windows and Office. What
e-mail program are you using?
Wow...a long post but I just wanted to make it really clear what I was
doing. I'm most concerend that I'm not using the code properly or have
named
something incorrectly.

Again, many thanks for your help and assistance with this issue.

Adam




:

You need to specify how the combo box will get the rows you see when
you
click the down arrow. This is the combo box Row Source. It is
different
from the Control Source. A combo box, like a text box (or chekc box,
label,
and everything else on a form) is called a control. A control is
bound
if
it is linked to a field in the form's underlying table. That is the
control's Control Source. If you need to save the information you
select
from a combo box, you need to bind the combo box to a Control Source
by
selecting the name of the field. In order to do this the form itself
needs
to be bound to a record source such as a table or query.
Some forms don't need to be bound to a Record Source (search forms,
for
instance), and not every control needs to be bound to a field. It
depends
on the situation.
Anyhow, you need to specify the combo box Row Source. When you click
the
three buttons as described you will see a query design grid. You can
select
the table you need, then select the fields you need, as I think I
already
described. Again, the details depend on your situation. When you are
done,
click View > Datasheet to see if you are getting the expected results.
If
so, close the query, and click OK when prompted about updating the
property.
Now you can enter the code as described for the command button. Do
not
over-complicate it. Create a command button. Go into its properties
and
name it cmdNotify or whatever you wish (it's good to leave spaces out
of
it,
and to use only letters, numbers, and underscores). Now go to the
Event
tab
and proceed as described with the Click event.
If you are not getting the expected results for the row source, post
details. One step at a time here; once the combo box is working, feel
free
to post more questions. If you can't get it to work, be as specific
as
possible about what you have tried.

Hello freakazeud
Really appreciate the effort you and BruceM are putting in.

Unfortunately, however, I have not yet cracked it....

I deleted my old buttons and have created a new button with only the
following code:

Private Sub cmdNotify_Click()
Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "adamstest"
strToWhom = Me.email.Column(2)
strMsgBody = "adamstestcontent"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

End Sub

My comboSource has a Data Control Source entitled 'email'. I created
three
columns in my table with those values and the email address is in
the
3rd
one
(i.e. Column2).

I have saved this and selected my email, pressed the button...and
nothing
happens....

I tried also changing 'email' to the Name of the contact email combo
box
but
this didn't seem to work either. I feel I am pretty close thanks to
your
help
but just can't quite get it....

Cheers,

Adam


:

Hi,
Forms/reports hold controls...fields are in tables, so you want to
reference
a bound contorl which holds the value. It doesn't really matter
what
this
control is textbox/combo...the only difference is that refering to
the
default value property of comboboxes will return the bound column
value.
If
the email is in that one then you are fine...if not then you need
to
reference the correct column. The column count is zero based so
refering
to
the second column would be:

Me.YourCombo.Column(1)

So you can have the actual email in the second column and an alias
in
the
first column which is the only one displayed (specify the column
width
in
the
combobox format properties).
To add the email code open your form in design view...open the
button's
property dialog. Go to the event tab and browse for the on click
event.
Select [event procedure] from the drop down list and click the
"..."
next
to
it. This will open the VBA editor with a preformatted on click
routine
for
you. Add the SendObject code in between the beginning and end of
the
procedure. In the 'To' argument of the sendobject code refernce the
combobox
(either its default value property or some specific column) as
somewhat
described earlier in the small sample. Close the editor...open form
in
form
view...select something in the combo...press the button and see
what
happens
:) You just have written your first custom VBA procedure.
HTH
Good luck
--
 
A

Adam

Hi BruceM,

Tried this new method you suggested, and it's working in respect that after
pressing the button, it opens an outlook window addressed to the preson
specified in the drop down list with the subject header and message
specified...however I don't want a message box to pop up, rather, I just want
the email to be sent. Is there a way to prevent the email box popping up and
just sending the message onwards?

Many thanks,

Adam
 
B

BruceM

I think you need SendObject for that, although I expect there is code of
which I am unaware that can accomplish that within the FollowHyperlink
context. Have you tried changing the True to False at the end of
SendObject? True would cause the e-mail to be opened for editing; False
would just send it on its way. I assumed that since you had True in the
code you meant to open the e-mail for editing.
 
A

Adam

Wow...Success.

By changing to FALSE (I had previously removed the TRUE statement but not
replaced it) the error message did not appear and the message sent. I was
just about to give up.

Many many thanks for your help in resolving this issue. Much appreciated.

Best Regards,

Adam
 
B

BruceM

True is the same as leaving it blank. When I checked into it I learned that
using False tends to make that error go away. Something's not right with
that, but I'm glad to hear you got it sorted out. Glad I could help.
 
S

Simple question just where is the sent

Thanks your idea is very good...I can tell that you know about computers and
programs, I do not know . Please help me , I am just trying to sent an email
with photos . I cannot find the key that I should click to sent the messeg
only this simple question . Please if you know where is the key that I have
to click just to send it please let me know. I am using picasa.

Happy Holidays, Aminta
my email is (e-mail address removed)
freakazeud said:
Hi,
do you have a control on the form where this action is being executed which
is bound to the email table field? If so then you need to reference it
correctly.
I would suggest you do not use macros...they are very limited and cannot
handle error handling (at least not yet). Within VBA you can similarly use
the Sendobject method and just reference the form control which holds the
email value e.g.:

Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = "Your Subject"
strToWhom = Me.YourControl 'referencing the form control which holds the
email address
strMsgBody = "Your Body text goes here!"

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

HTH
Good luck
--
Oli-S
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de


Adam said:
Hello all,

I have created a button called 'Notify person' on a form. The purpose of
this button is to notify a member of staff when an entry into a table has
been made against his / her name.

I have attempted to do this as follows.

In the properties tab of my button, on the event tab, at the On click option
I have created a Macro.

I have selected the SendObject command.

I wish to send the email to the address of the person whose name features in
a field which I have created on my table, entitled 'email'. As such in the
'to' column of the action arguments (in the macro) I have entered

This however, does not work and I receive the message (unknown message
recipient, the message was not sent).

I guess I'm just not specifying the field properly, but essentially I want
to send the email to whatever address is specified in the 'to' column.

Many thanks in advance.

Adam
[/QUOTE][/QUOTE]
 

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