Field coding for E-mail

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form, having an e-mail field linked to a table/field type that is,
“hyperlink". I used the following code in the, “Onclick†behind the field
properties:

Private Sub email_Click()
On Error GoTo ErrLine
DoCmd.SendObject acSendNoObject, , , email, , , , , True
ExitLine:
Exit Sub
ErrLine:
Resume ExitLine
End Sub

Also, for each field in both forms under Properties/Format, “Is Hyperlink†I
have a, “Yes†indicated.

Once completed, the user can type an e-mail address. After you type in the
address, you can then click on the hyperlinked field to send e-mail.


I have two problems:

When I send e-mail from the form, the following appears on the “To:†line:
[email protected]#http://[email protected]#

After I close the e-mail form; I then get linked to my hotmail.com main page.


The second problem is in the editing of the field. If I have to edit/change
the e-mail address in this field; I have to tab into it and retype the whole
e-mail address. Otherwise, it links (opens) the e-mail form.


John
 
Hi John

Setting the IsHyperlink property of a textbox does two things:
1. It changes the Value property of the textbox to:
#<text>#http://<text>#
2. It changes the behaviour of the textbox so that clicking on it
automatically follows the hyperlink.

Now, you also have a click event for the textbox, so when you click on it,
it does two things:
1. Performs a SendObject to #<email-address>#http://<email-address>#
(your Click event procedure)
2. Navigates your browser to http://<email-domain-name>
(following the hyperlink)

First you need to turn IsHyperlink off. This will remove behaviour #2 and
will stop the textbox value being modified, so your SendObject will go to
the correct address.

Now, you will still have the problem that entering the textbox via a click
will send mail instead of allowing you to edit the text.

I suggest you add a small command button next to the textbox to send email
and put your code in its Click event instead of the textbox.

Also, for a simple email without attachments, cc, bcc, etc, it's easier to
use FollowHyperlink instead of SendObject:

Private Sub cmdSendEmail_Click()
Application.FollowHyperlink "mailto:" & email
End Sub
 
OK, thanks a-lot. Everything worked. Just a couple of followup questions:

When I close the e-mail form, or send e-mail, MS Word (that I use as the
E-mail editor) remains open. How do I get this to close
automatically/transparently? And will creating e-mail use whatever e-mail
editor the end user chooses as their default?

thanks again!
John

Graham Mandeno said:
Hi John

Setting the IsHyperlink property of a textbox does two things:
1. It changes the Value property of the textbox to:
#<text>#http://<text>#
2. It changes the behaviour of the textbox so that clicking on it
automatically follows the hyperlink.

Now, you also have a click event for the textbox, so when you click on it,
it does two things:
1. Performs a SendObject to #<email-address>#http://<email-address>#
(your Click event procedure)
2. Navigates your browser to http://<email-domain-name>
(following the hyperlink)

First you need to turn IsHyperlink off. This will remove behaviour #2 and
will stop the textbox value being modified, so your SendObject will go to
the correct address.

Now, you will still have the problem that entering the textbox via a click
will send mail instead of allowing you to edit the text.

I suggest you add a small command button next to the textbox to send email
and put your code in its Click event instead of the textbox.

Also, for a simple email without attachments, cc, bcc, etc, it's easier to
use FollowHyperlink instead of SendObject:

Private Sub cmdSendEmail_Click()
Application.FollowHyperlink "mailto:" & email
End Sub

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

John Phelan said:
I have a form, having an e-mail field linked to a table/field type that is,
"hyperlink". I used the following code in the, "Onclick" behind the field
properties:

Private Sub email_Click()
On Error GoTo ErrLine
DoCmd.SendObject acSendNoObject, , , email, , , , , True
ExitLine:
Exit Sub
ErrLine:
Resume ExitLine
End Sub

Also, for each field in both forms under Properties/Format, "Is Hyperlink"
I
have a, "Yes" indicated.

Once completed, the user can type an e-mail address. After you type in the
address, you can then click on the hyperlinked field to send e-mail.


I have two problems:

When I send e-mail from the form, the following appears on the "To:" line:
[email protected]#http://[email protected]#

After I close the e-mail form; I then get linked to my hotmail.com main
page.


The second problem is in the editing of the field. If I have to
edit/change
the e-mail address in this field; I have to tab into it and retype the
whole
e-mail address. Otherwise, it links (opens) the e-mail form.


John
 
Hi John

I believe that when you use Word as your email editor in Outlook, an
instance of Word is left open in the background all the time. I guess this
is to avoid the overhead of launching a new instance every time you want to
read or edit an email. The Word window should not be visible though.

Maybe you could post a question in one of the Outlook newsgroups for more
information.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

John Phelan said:
OK, thanks a-lot. Everything worked. Just a couple of followup
questions:

When I close the e-mail form, or send e-mail, MS Word (that I use as the
E-mail editor) remains open. How do I get this to close
automatically/transparently? And will creating e-mail use whatever
e-mail
editor the end user chooses as their default?

thanks again!
John

Graham Mandeno said:
Hi John

Setting the IsHyperlink property of a textbox does two things:
1. It changes the Value property of the textbox to:
#<text>#http://<text>#
2. It changes the behaviour of the textbox so that clicking on it
automatically follows the hyperlink.

Now, you also have a click event for the textbox, so when you click on
it,
it does two things:
1. Performs a SendObject to #<email-address>#http://<email-address>#
(your Click event procedure)
2. Navigates your browser to http://<email-domain-name>
(following the hyperlink)

First you need to turn IsHyperlink off. This will remove behaviour #2
and
will stop the textbox value being modified, so your SendObject will go to
the correct address.

Now, you will still have the problem that entering the textbox via a
click
will send mail instead of allowing you to edit the text.

I suggest you add a small command button next to the textbox to send
email
and put your code in its Click event instead of the textbox.

Also, for a simple email without attachments, cc, bcc, etc, it's easier
to
use FollowHyperlink instead of SendObject:

Private Sub cmdSendEmail_Click()
Application.FollowHyperlink "mailto:" & email
End Sub

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

John Phelan said:
I have a form, having an e-mail field linked to a table/field type that
is,
"hyperlink". I used the following code in the, "Onclick" behind the
field
properties:

Private Sub email_Click()
On Error GoTo ErrLine
DoCmd.SendObject acSendNoObject, , , email, , , , , True
ExitLine:
Exit Sub
ErrLine:
Resume ExitLine
End Sub

Also, for each field in both forms under Properties/Format, "Is
Hyperlink"
I
have a, "Yes" indicated.

Once completed, the user can type an e-mail address. After you type in
the
address, you can then click on the hyperlinked field to send e-mail.


I have two problems:

When I send e-mail from the form, the following appears on the "To:"
line:
[email protected]#http://[email protected]#

After I close the e-mail form; I then get linked to my hotmail.com main
page.


The second problem is in the editing of the field. If I have to
edit/change
the e-mail address in this field; I have to tab into it and retype the
whole
e-mail address. Otherwise, it links (opens) the e-mail form.


John
 

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

Back
Top