Emailing from database

G

Guest

I have a form that has a list of email addresses. I would like to put a
button next to each name so the user can just click and have an email open
with the address already entered. So I have..
Name1 Email1
Name2 Email2
So if someone clicks the button next to email1 then the value in that
control will be put into the email address to send. I know this can be done
but have not had any luck. Can someone give me a clue? Thanks.
 
T

Tom van Stiphout

On Tue, 13 Nov 2007 18:17:00 -0800, Sarah at DaVita

Rather than a button you can use a hyperlink with:
mailto: (e-mail address removed)

-Tom.
 
G

Guest

Hi Sarah
From what I can understand, you want to compile a list of names for an
email. I have an email selection form that has a combo box with a list of
names, There are three columns, PersonNo, PersonName, EmailAddress. There
is another unbound text box called txtIndividualList. You select a name from
the combo, select a button which adds the name to the existing names in the
list. It then puts a semi colon after the name.

Me![txtIndividualList] = Me![txtIndividualList] &
Me![NameCombo].Column(2) & ";"

Does that answer your question?
 
G

Guest

Hi Sarah,

try using the SendObject method ...
Dim recipient as string
recipient = Forms!MyForm!txtemailaddress
'''place the recipient variable in the 'To' in the following method. Create
other variables to further automate the process.
DoCmd.SendObject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject,
MessageText, EditMessage, TemplateFile)

Using this allows you to send a predetermined message without having to work
within an email client or alternatively setting the EditMessage variable to
True will open the email client for you to edit the message before sending.

regards,
Nick.
 
G

Guest

I go many responses but since I am new at this I don't really understand
them. Imagin a button next to each email address. If I click on the button
next to email2 then outlook would open a mail window with the To filled in as
the value of email2 and then the user will fill in the other fields and
attached what ever they need to.

NevilleT said:
Hi Sarah
From what I can understand, you want to compile a list of names for an
email. I have an email selection form that has a combo box with a list of
names, There are three columns, PersonNo, PersonName, EmailAddress. There
is another unbound text box called txtIndividualList. You select a name from
the combo, select a button which adds the name to the existing names in the
list. It then puts a semi colon after the name.

Me![txtIndividualList] = Me![txtIndividualList] &
Me![NameCombo].Column(2) & ";"

Does that answer your question?

Sarah at DaVita said:
I have a form that has a list of email addresses. I would like to put a
button next to each name so the user can just click and have an email open
with the address already entered. So I have..
Name1 Email1
Name2 Email2
So if someone clicks the button next to email1 then the value in that
control will be put into the email address to send. I know this can be done
but have not had any luck. Can someone give me a clue? Thanks.
 
G

Guest

Hi Sarah,

What you have described is best solved with the SendObject method. However,
a button next to each email address means a lot of repeated code and a
limitation on your form as far as adding more email contacts. A better
solution would be to have one button with the code executing with the click
event and either a listbox or a dropdown box retrieving the email address
from a table.

Rowsource for the listbox or combo box = "SELECT Mytable.Emailaddress,
Mytable.Name FROM MyTable;"

The click event code for the button would be something like:

Private Sub Command1_Click()
On Error GoTo Errtrp
Dim Ema As String

Erm = Me.List0 'replace list0 with the name of your control holding the
email names

DoCmd.SendObject acSendNoObject, , , ema, , , , , True
Exittrp:
Exit Sub
Errtrp:
Msgbox Err.number & ": " & Err.Description
Resume Exittrp

End Sub

The code will take whatever is highlighted in the listbox or selected in a
combobox and use the email address to open up your email client with the
address already populated.

What I have given you is fairly simple but you can create a lot more
variables to parse things like subject, message etc before opening the email
client.

Regards,
Nick
Sarah at DaVita said:
I go many responses but since I am new at this I don't really understand
them. Imagin a button next to each email address. If I click on the button
next to email2 then outlook would open a mail window with the To filled in as
the value of email2 and then the user will fill in the other fields and
attached what ever they need to.

NevilleT said:
Hi Sarah
From what I can understand, you want to compile a list of names for an
email. I have an email selection form that has a combo box with a list of
names, There are three columns, PersonNo, PersonName, EmailAddress. There
is another unbound text box called txtIndividualList. You select a name from
the combo, select a button which adds the name to the existing names in the
list. It then puts a semi colon after the name.

Me![txtIndividualList] = Me![txtIndividualList] &
Me![NameCombo].Column(2) & ";"

Does that answer your question?

Sarah at DaVita said:
I have a form that has a list of email addresses. I would like to put a
button next to each name so the user can just click and have an email open
with the address already entered. So I have..
Name1 Email1
Name2 Email2
So if someone clicks the button next to email1 then the value in that
control will be put into the email address to send. I know this can be done
but have not had any luck. Can someone give me a clue? Thanks.
 
G

Guest

Yes a list would be great if I have a large number of email addresses but I
don't. I have put the code below in the click event but keep getting the
error of invlaid use of null. Can someone tell me why this is?
Private Sub email1_Click()
On Error GoTo Err_email1_Click

Dim Recipient As String
Recipient = Me.JVD_GlContactEmail1

DoCmd.SendObject acSendNoObject, , , Recipient

Exit_email1_Click:
Exit Sub

Err_email1_Click:
MsgBox Err.Description
Resume Exit_email1_Click

End Sub

Biz Enhancer said:
Hi Sarah,

What you have described is best solved with the SendObject method. However,
a button next to each email address means a lot of repeated code and a
limitation on your form as far as adding more email contacts. A better
solution would be to have one button with the code executing with the click
event and either a listbox or a dropdown box retrieving the email address
from a table.

Rowsource for the listbox or combo box = "SELECT Mytable.Emailaddress,
Mytable.Name FROM MyTable;"

The click event code for the button would be something like:

Private Sub Command1_Click()
On Error GoTo Errtrp
Dim Ema As String

Erm = Me.List0 'replace list0 with the name of your control holding the
email names

DoCmd.SendObject acSendNoObject, , , ema, , , , , True
Exittrp:
Exit Sub
Errtrp:
Msgbox Err.number & ": " & Err.Description
Resume Exittrp

End Sub

The code will take whatever is highlighted in the listbox or selected in a
combobox and use the email address to open up your email client with the
address already populated.

What I have given you is fairly simple but you can create a lot more
variables to parse things like subject, message etc before opening the email
client.

Regards,
Nick
Sarah at DaVita said:
I go many responses but since I am new at this I don't really understand
them. Imagin a button next to each email address. If I click on the button
next to email2 then outlook would open a mail window with the To filled in as
the value of email2 and then the user will fill in the other fields and
attached what ever they need to.

NevilleT said:
Hi Sarah
From what I can understand, you want to compile a list of names for an
email. I have an email selection form that has a combo box with a list of
names, There are three columns, PersonNo, PersonName, EmailAddress. There
is another unbound text box called txtIndividualList. You select a name from
the combo, select a button which adds the name to the existing names in the
list. It then puts a semi colon after the name.

Me![txtIndividualList] = Me![txtIndividualList] &
Me![NameCombo].Column(2) & ";"

Does that answer your question?

:

I have a form that has a list of email addresses. I would like to put a
button next to each name so the user can just click and have an email open
with the address already entered. So I have..
Name1 Email1
Name2 Email2
So if someone clicks the button next to email1 then the value in that
control will be put into the email address to send. I know this can be done
but have not had any luck. Can someone give me a clue? Thanks.
 
G

Guest

Sarah,
Err 94 "invalid use of null" is indicating that an expected variable is not
being found. My first guess is that the declared field in in your code is
empty. You can check this by putting a breakpoint on the "Docmd" line of your
code, and placing your cursor over the "Recipient" part of "Recipient =
Me.JVD_GlContactEmail1" when you run the code and it stops on the breakpoint.
If this shows "Recipient = "" " then it is not picking up the information
from your form.

Regards,
Nick
Sarah at DaVita said:
Yes a list would be great if I have a large number of email addresses but I
don't. I have put the code below in the click event but keep getting the
error of invlaid use of null. Can someone tell me why this is?
Private Sub email1_Click()
On Error GoTo Err_email1_Click

Dim Recipient As String
Recipient = Me.JVD_GlContactEmail1

DoCmd.SendObject acSendNoObject, , , Recipient

Exit_email1_Click:
Exit Sub

Err_email1_Click:
MsgBox Err.Description
Resume Exit_email1_Click

End Sub

Biz Enhancer said:
Hi Sarah,

What you have described is best solved with the SendObject method. However,
a button next to each email address means a lot of repeated code and a
limitation on your form as far as adding more email contacts. A better
solution would be to have one button with the code executing with the click
event and either a listbox or a dropdown box retrieving the email address
from a table.

Rowsource for the listbox or combo box = "SELECT Mytable.Emailaddress,
Mytable.Name FROM MyTable;"

The click event code for the button would be something like:

Private Sub Command1_Click()
On Error GoTo Errtrp
Dim Ema As String

Erm = Me.List0 'replace list0 with the name of your control holding the
email names

DoCmd.SendObject acSendNoObject, , , ema, , , , , True
Exittrp:
Exit Sub
Errtrp:
Msgbox Err.number & ": " & Err.Description
Resume Exittrp

End Sub

The code will take whatever is highlighted in the listbox or selected in a
combobox and use the email address to open up your email client with the
address already populated.

What I have given you is fairly simple but you can create a lot more
variables to parse things like subject, message etc before opening the email
client.

Regards,
Nick
Sarah at DaVita said:
I go many responses but since I am new at this I don't really understand
them. Imagin a button next to each email address. If I click on the button
next to email2 then outlook would open a mail window with the To filled in as
the value of email2 and then the user will fill in the other fields and
attached what ever they need to.

:

Hi Sarah
From what I can understand, you want to compile a list of names for an
email. I have an email selection form that has a combo box with a list of
names, There are three columns, PersonNo, PersonName, EmailAddress. There
is another unbound text box called txtIndividualList. You select a name from
the combo, select a button which adds the name to the existing names in the
list. It then puts a semi colon after the name.

Me![txtIndividualList] = Me![txtIndividualList] &
Me![NameCombo].Column(2) & ";"

Does that answer your question?

:

I have a form that has a list of email addresses. I would like to put a
button next to each name so the user can just click and have an email open
with the address already entered. So I have..
Name1 Email1
Name2 Email2
So if someone clicks the button next to email1 then the value in that
control will be put into the email address to send. I know this can be done
but have not had any luck. Can someone give me a clue? Thanks.
 
G

Guest

Found it. Thanks for your help!!!

Biz Enhancer said:
Sarah,
Err 94 "invalid use of null" is indicating that an expected variable is not
being found. My first guess is that the declared field in in your code is
empty. You can check this by putting a breakpoint on the "Docmd" line of your
code, and placing your cursor over the "Recipient" part of "Recipient =
Me.JVD_GlContactEmail1" when you run the code and it stops on the breakpoint.
If this shows "Recipient = "" " then it is not picking up the information
from your form.

Regards,
Nick
Sarah at DaVita said:
Yes a list would be great if I have a large number of email addresses but I
don't. I have put the code below in the click event but keep getting the
error of invlaid use of null. Can someone tell me why this is?
Private Sub email1_Click()
On Error GoTo Err_email1_Click

Dim Recipient As String
Recipient = Me.JVD_GlContactEmail1

DoCmd.SendObject acSendNoObject, , , Recipient

Exit_email1_Click:
Exit Sub

Err_email1_Click:
MsgBox Err.Description
Resume Exit_email1_Click

End Sub

Biz Enhancer said:
Hi Sarah,

What you have described is best solved with the SendObject method. However,
a button next to each email address means a lot of repeated code and a
limitation on your form as far as adding more email contacts. A better
solution would be to have one button with the code executing with the click
event and either a listbox or a dropdown box retrieving the email address
from a table.

Rowsource for the listbox or combo box = "SELECT Mytable.Emailaddress,
Mytable.Name FROM MyTable;"

The click event code for the button would be something like:

Private Sub Command1_Click()
On Error GoTo Errtrp
Dim Ema As String

Erm = Me.List0 'replace list0 with the name of your control holding the
email names

DoCmd.SendObject acSendNoObject, , , ema, , , , , True
Exittrp:
Exit Sub
Errtrp:
Msgbox Err.number & ": " & Err.Description
Resume Exittrp

End Sub

The code will take whatever is highlighted in the listbox or selected in a
combobox and use the email address to open up your email client with the
address already populated.

What I have given you is fairly simple but you can create a lot more
variables to parse things like subject, message etc before opening the email
client.

Regards,
Nick
:

I go many responses but since I am new at this I don't really understand
them. Imagin a button next to each email address. If I click on the button
next to email2 then outlook would open a mail window with the To filled in as
the value of email2 and then the user will fill in the other fields and
attached what ever they need to.

:

Hi Sarah
From what I can understand, you want to compile a list of names for an
email. I have an email selection form that has a combo box with a list of
names, There are three columns, PersonNo, PersonName, EmailAddress. There
is another unbound text box called txtIndividualList. You select a name from
the combo, select a button which adds the name to the existing names in the
list. It then puts a semi colon after the name.

Me![txtIndividualList] = Me![txtIndividualList] &
Me![NameCombo].Column(2) & ";"

Does that answer your question?

:

I have a form that has a list of email addresses. I would like to put a
button next to each name so the user can just click and have an email open
with the address already entered. So I have..
Name1 Email1
Name2 Email2
So if someone clicks the button next to email1 then the value in that
control will be put into the email address to send. I know this can be done
but have not had any luck. Can someone give me a clue? Thanks.
 

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