Emailing from an Access Form

A

Anh Nguyen

HELP SOMEONE!
I have created a simple form that has combo boxes where you can select
information from a row source (table) and also text boxes where you enter any
text in it and I just want to create the email function so that it just
emails out what is filled in the combo boxes and the text boxes as a simple
text email. I know how to send a report from a form but not this. I hope it
makes some sense.
For example:
Drop down combo box has country codes and then there are text boxes where
you enter descriptions and statuses on a particular situation. And I just
want to have a command button that sends a simple text email out.

And how do I create email address groups in Access. I am able to import my
email addresses from outlook but when i sent out these emails from the form
it's to a particular group of people not just one individual.

Thanks in advance for any help I can get!!!
 
D

Dirk Goldgar

Anh Nguyen said:
HELP SOMEONE!
I have created a simple form that has combo boxes where you can select
information from a row source (table) and also text boxes where you
enter any text in it and I just want to create the email function so
that it just emails out what is filled in the combo boxes and the
text boxes as a simple text email. I know how to send a report from
a form but not this. I hope it makes some sense.
For example:
Drop down combo box has country codes and then there are text boxes
where you enter descriptions and statuses on a particular situation.
And I just want to have a command button that sends a simple text
email out.

You'd build up the body of the message as a text string, composing it by
concatenating from the various controls. Then you'd use SendObject to
send the message without any object attached. For example,

Dim strMessage As String

strMessage = _
"You chose country " & Me.cboCountry & _
", and filled in color " & Me.txtColor & _
" and size " & Me.txtSize & "." & _
vbCrLf & "That's all; here's another line for the message."

DoCmd.SendObject acSendNoObject, , , _
"[email protected]", , , _
"Your Message Subject", _
strMessage, _
False
And how do I create email address groups in Access. I am able to
import my email addresses from outlook but when i sent out these
emails from the form it's to a particular group of people not just
one individual.

You wouldn't need to create the address group in Access. It's the mail
program's job to resolve the recipient address you gave it, so you
should be able to specify the group name for the recipient, and let
Outlook resolve it to the individual addresses. Or you can provide a
semicolon-delimited list as a string to the <To> argument of SendObject.
 
A

Anh Nguyen

Thanks Dirk,

I am getting an error now: Compile Error: Method or data member not found.
Not sure why... The item is true. I am getting it here: Me.cboCountryCode.

Most appreciated!
 
D

Dirk Goldgar

Anh Nguyen said:
Thanks Dirk,

I am getting an error now: Compile Error: Method or data member not
found. Not sure why... The item is true. I am getting it here:
Me.cboCountryCode.

You'd best show your actual code, but I'm guessing that cboCountryCode
is not actually the name of the control in question. The names you use
must either be the names of controls on the form or the names of fields
in the form's recordsource.
 
A

Anh Nguyen

Thanks for being so patient... I have been out of the VB world for 2 years
and have not been using it and totally forgot everything... So bare with
me...

I have:

Private Sub Email_Click()

Dim strEmail As String

strEmail = _
" " & Me.cboCountryCode & _
"; " & Me.cboSiteID & _
"; " & Me.txtTicketNo & "."

varEmailTo = " Select OSD Contacts from the GAL "

DoCmd.SendObject acSendNoObject, , , _
, , [varEmailTo], , strEmail, , False

End Sub

I am thinking I am missing some thing for those combo boxes and text
boxes... When I am in form view the combo boxes and text boxse has #Name? in
it like it doesn't recognize the Row Source that I have it connected to. Not
sure what I am doing wrong. Please help!

Thanks again DIRK!
 
D

Dirk Goldgar

Anh Nguyen said:
Thanks for being so patient... I have been out of the VB world for 2
years and have not been using it and totally forgot everything... So
bare with me...

I have:

Private Sub Email_Click()

Dim strEmail As String

strEmail = _
" " & Me.cboCountryCode & _
"; " & Me.cboSiteID & _
"; " & Me.txtTicketNo & "."

varEmailTo = " Select OSD Contacts from the GAL "

DoCmd.SendObject acSendNoObject, , , _
, , [varEmailTo], , strEmail, , False

End Sub

I am thinking I am missing some thing for those combo boxes and text
boxes... When I am in form view the combo boxes and text boxse has
#Name? in it like it doesn't recognize the Row Source that I have it
connected to. Not sure what I am doing wrong. Please help!

Please post:

1. The recordsource of the form. If it's a table, post the names of the
relevant fields. If it's a query, post the SQL of the query. If the
form is unbound -- has no recordsource -- state that fact.

2. The Name and ControlSource properties of each of the text boxes and
combo boxes on the form.

What is varEmailTo? Is it a variable? If so, where is it declared?
Why do you have square brackets around it? Should it have that leading
space in the value you assigned to it?
 
A

Anh Nguyen

Ok Dirk Here we go again!

Private Sub Email_Click()

Dim txtTicketNo As TextBox
Dim cboCountryCode As ComboBox
Dim cboSiteID As ComboBox
Dim strEmail As String

strEmail = _
" " & Me.cboCountryCode.RowSource & _
"; " & Me.cboSiteID.RowSource & _
"; " & Me.txtTicketNo & "."

varEmailTo = "Select OSD Contacts from the GAL"

DoCmd.SendObject acSendNoObject, , , _
, , [varEmailTo], , strEmail, , False

End Sub

1: The recordsource is a table so I do have that stated.

2: The name and controlsource of the properties are the same

varEmaiTo is a variable that is declared in the Send Object.

Thanks a billion times!

Dirk Goldgar said:
Anh Nguyen said:
Thanks for being so patient... I have been out of the VB world for 2
years and have not been using it and totally forgot everything... So
bare with me...

I have:

Private Sub Email_Click()

Dim strEmail As String

strEmail = _
" " & Me.cboCountryCode & _
"; " & Me.cboSiteID & _
"; " & Me.txtTicketNo & "."

varEmailTo = " Select OSD Contacts from the GAL "

DoCmd.SendObject acSendNoObject, , , _
, , [varEmailTo], , strEmail, , False

End Sub

I am thinking I am missing some thing for those combo boxes and text
boxes... When I am in form view the combo boxes and text boxse has
#Name? in it like it doesn't recognize the Row Source that I have it
connected to. Not sure what I am doing wrong. Please help!

Please post:

1. The recordsource of the form. If it's a table, post the names of the
relevant fields. If it's a query, post the SQL of the query. If the
form is unbound -- has no recordsource -- state that fact.

2. The Name and ControlSource properties of each of the text boxes and
combo boxes on the form.

What is varEmailTo? Is it a variable? If so, where is it declared?
Why do you have square brackets around it? Should it have that leading
space in the value you assigned to it?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
D

Dirk Goldgar

Anh Nguyen said:
Ok Dirk Here we go again!

Private Sub Email_Click()

Dim txtTicketNo As TextBox
Dim cboCountryCode As ComboBox
Dim cboSiteID As ComboBox
Dim strEmail As String

strEmail = _
" " & Me.cboCountryCode.RowSource & _
"; " & Me.cboSiteID.RowSource & _
"; " & Me.txtTicketNo & "."

varEmailTo = "Select OSD Contacts from the GAL"

DoCmd.SendObject acSendNoObject, , , _
, , [varEmailTo], , strEmail, , False

End Sub

1: The recordsource is a table so I do have that stated.

2: The name and controlsource of the properties are the same

varEmaiTo is a variable that is declared in the Send Object.

Thanks a billion times!

Dirk Goldgar said:
Please post:

1. The recordsource of the form. If it's a table, post the names of
the relevant fields. If it's a query, post the SQL of the query.
If the form is unbound -- has no recordsource -- state that fact.

2. The Name and ControlSource properties of each of the text boxes
and combo boxes on the form.

What is varEmailTo? Is it a variable? If so, where is it declared?
Why do you have square brackets around it? Should it have that
leading space in the value you assigned to it?

I'm afraid you didn't answer all my questions in quite the way I'd
hoped. I think I see what may be going wrong, but I need still more
information to be sure.

1. What are the names of the fields in the table that is the
recordsource of the form?

2: You say "The name and controlsource of the properties are the same."
Do you mean your table has fields actually named "txtTicketNo",
"cboCountryCode", and "cboSiteID"? That would be unusual naming for
fields.

3. Again, please post the Name property and the ControlSource property
of each of the three controls you refer to in your code.

4. These declarations:
Dim txtTicketNo As TextBox
Dim cboCountryCode As ComboBox
Dim cboSiteID As ComboBox

.... should *not* be there at all. They serve no purpose, and can only
confuse matters.

5. You write:
varEmaiTo is a variable that is declared in the Send Object.

No, it isn't. There is no declaration for it in the code that I can
see. If you aren't posting all the code in the procedure, you are not
helping things by leaving things out. If you did post all the code,
then that variable is not declared.
 
A

Anh Nguyen

Thanks Dirk... I figured what I did wrong... It was something real simple. I
had named one of the items incorrectly. Silly me.... well it's working now.
And thanks again for your time and patience!

Anh

Dirk Goldgar said:
Anh Nguyen said:
Ok Dirk Here we go again!

Private Sub Email_Click()

Dim txtTicketNo As TextBox
Dim cboCountryCode As ComboBox
Dim cboSiteID As ComboBox
Dim strEmail As String

strEmail = _
" " & Me.cboCountryCode.RowSource & _
"; " & Me.cboSiteID.RowSource & _
"; " & Me.txtTicketNo & "."

varEmailTo = "Select OSD Contacts from the GAL"

DoCmd.SendObject acSendNoObject, , , _
, , [varEmailTo], , strEmail, , False

End Sub

1: The recordsource is a table so I do have that stated.

2: The name and controlsource of the properties are the same

varEmaiTo is a variable that is declared in the Send Object.

Thanks a billion times!

Dirk Goldgar said:
Please post:

1. The recordsource of the form. If it's a table, post the names of
the relevant fields. If it's a query, post the SQL of the query.
If the form is unbound -- has no recordsource -- state that fact.

2. The Name and ControlSource properties of each of the text boxes
and combo boxes on the form.

What is varEmailTo? Is it a variable? If so, where is it declared?
Why do you have square brackets around it? Should it have that
leading space in the value you assigned to it?

I'm afraid you didn't answer all my questions in quite the way I'd
hoped. I think I see what may be going wrong, but I need still more
information to be sure.

1. What are the names of the fields in the table that is the
recordsource of the form?

2: You say "The name and controlsource of the properties are the same."
Do you mean your table has fields actually named "txtTicketNo",
"cboCountryCode", and "cboSiteID"? That would be unusual naming for
fields.

3. Again, please post the Name property and the ControlSource property
of each of the three controls you refer to in your code.

4. These declarations:
Dim txtTicketNo As TextBox
Dim cboCountryCode As ComboBox
Dim cboSiteID As ComboBox

.... should *not* be there at all. They serve no purpose, and can only
confuse matters.

5. You write:
varEmaiTo is a variable that is declared in the Send Object.

No, it isn't. There is no declaration for it in the code that I can
see. If you aren't posting all the code in the procedure, you are not
helping things by leaving things out. If you did post all the code,
then that variable is not declared.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Top