Opening email from a form

C

CarolM

Hi Guys

How are you all?, hope you're all welll and dandy :)

Hope you can help me?, i am creating a form and on the form we will need to
add in a customers email address.

what i would like to be able to do is when you click on the email address,
for outlook to open and insert the email address - is this possible at all?

Many thanks as always

Carolx
 
R

Rick Brandt

CarolM said:
Hi Guys

How are you all?, hope you're all welll and dandy :)

Hope you can help me?, i am creating a form and on the form we will need to
add in a customers email address.

what i would like to be able to do is when you click on the email address,
for outlook to open and insert the email address - is this possible at all?

Many thanks as always

Check the help file for the SendObject function. If your Email address was a
Text field in a control on your form named CustomerEmail then the code would
look like...

DoCmd.SendObject acSendNoObject,,,Me!CustomerEmail,,,"Subject String","Message
Text",True
 
C

CarolM

Hi Rick

thanks for your reply.

I may be wrong but i thought the Sendobject function meant that you had to
actually "send" a file rather than just opening outlook and inserting the
email address?
 
R

Rick Brandt

CarolM said:
Hi Rick

thanks for your reply.

I may be wrong but i thought the Sendobject function meant that you had to
actually "send" a file rather than just opening outlook and inserting the
email address?

Note the second argument in my example...

DoCmd.SendObject acSendNoObject,,,Me!CustomerEmail,,,"Subject String","Message
Text",True
 
C

CarolM

Hi Rick

gosh, i am just not cut out for this - it's a bit like the blind leading the
blind :) sorry for my stupidness :)

Private Sub CustomerEmail_DblClick(Cancel As Integer)
Private Sub Form_DblClick(Cancel As Integer)
DoCmd.SendObject acSendNoObject, , , Me!CustomerEmail, , , "Subject String",
"Message Text", True
End Sub

I have inserted the code as per your instructions and i have the following
error message.

compile error: expected end sub

As a second part to the question (im so sorry to be such a pain), im
guessing that it is theoretically possible to insert other lines such as
something in the subject line such as "Customer Complaint" - is that correct?

Also, i have another text field which holds info something like....

I am writing to complain about the service i recvd in ........ the text
field is known as customercomplaint. Would it also be possible to put this
information into the body of the email?

Thank you so much for your help, i really appreciate it.

Carolx
 
S

scubadiver

Copy and paste the following into the "click" event on a button.


Private Sub SendEmail_Click()

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

strSubject = "Your Subject"
strToWhom = Me.email
strMsgBody = "Hello!"

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

End Sub




If you want to be really posh, put the following into your form's current
event and it will disable the button if there is not an email address in the
text box.

Private Sub Form_Current()

If Nz(Me.email) = "" Then
Me.SendEmail.Enabled = False
Else
Me.SendEmail.Enabled = True
End If

End Sub
 
R

Rick Brandt

CarolM said:
Hi Rick

gosh, i am just not cut out for this - it's a bit like the blind leading the
blind :) sorry for my stupidness :)

Private Sub CustomerEmail_DblClick(Cancel As Integer)
Private Sub Form_DblClick(Cancel As Integer)
DoCmd.SendObject acSendNoObject, , , Me!CustomerEmail, , , "Subject String",
"Message Text", True
End Sub

I have inserted the code as per your instructions and i have the following
error message.

compile error: expected end sub

Look at your code. You somehow have gotten the opening line for the Form's
double-click event *inside* the sub-routine for your Email's double-click event.
Just delete that second line.
As a second part to the question (im so sorry to be such a pain), im
guessing that it is theoretically possible to insert other lines such as
something in the subject line such as "Customer Complaint" - is that correct?

Certainly. You can assign text to variables and then insert the variable names
into those arguments or you can reference other controls on your form just as
you are for the Email address.
Also, i have another text field which holds info something like....

I am writing to complain about the service i recvd in ........ the text
field is known as customercomplaint. Would it also be possible to put this
information into the body of the email?

Yes, just use Me!customercomplaint in the Message Body argument.
 
S

scubadiver

Forgot to mention, You will need a requery line when you cycle through the
records.
 
C

CarolM

Hi Scubadiver

Thank you for your help - although, im still doing something wrong though
because it isnt working (god, i am sooo dumb!)

Here's what i have done

Text Box - go into the properties and go onto the on click (event procedure)
and then this is what i have

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

strSubject = "Oasis On-Line"
strToWhom = Me.email
strMsgBody = "Hello!"

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

End Sub

I then get the error message

method or data member not found and the private sub line is highlighted and
the ".email" is highlighted.

Many thanks all for your patience - i promise i'll get it eventually :)

x
 
S

scubadiver

[customeremail] should be replaced by the name of your button
Me.email - should be replaced by the text box you are referring to.
 
S

scubadiver

Use a BUTTON, not a text box!!!!

LoL

CarolM said:
Hi Scubadiver

Thank you for your help - although, im still doing something wrong though
because it isnt working (god, i am sooo dumb!)

Here's what i have done

Text Box - go into the properties and go onto the on click (event procedure)
and then this is what i have

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

strSubject = "Oasis On-Line"
strToWhom = Me.email
strMsgBody = "Hello!"

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

End Sub

I then get the error message

method or data member not found and the private sub line is highlighted and
the ".email" is highlighted.

Many thanks all for your patience - i promise i'll get it eventually :)

x
 
Top