Email message

L

LindaBee

I have created a mcaro that sends an email to a manager and have inserted the
email address and subject but I would like to insert text from different
fields but when I try either the text does not display or I get an error
message.

Click OK to return to the action argument or conditional expression where
expression appears, and then correct.

=[txt1] â€& Me.Fname& " “ & Me.txt2 & “ “& Me.[LID (IF KNOWN)]& “ “ & Me.txt3
& “ " &Me. [Job Title] & " “ & Me.txt4 &†" & Me.[Section/Team] & “ " &
Me.txt4 & “ " & Me.txt6


Where am I going wrong. I am entering this in the Message text

Thanks in advance
 
W

Wayne-I-M

where have you put this code ?

You say its a macro but this looks (sort of) like an onEvent code
Where am I going wrong. I am entering this in the Message text
Where the Message Text ?


--
Wayne
Manchester, England.



LindaBee said:
I have created a mcaro that sends an email to a manager and have inserted the
email address and subject but I would like to insert text from different
fields but when I try either the text does not display or I get an error
message.

Click OK to return to the action argument or conditional expression where
expression appears, and then correct.

=[txt1] â€& Me.Fname& " “ & Me.txt2 & “ “& Me.[LID (IF KNOWN)]& “ “ & Me.txt3
& “ " &Me. [Job Title] & " “ & Me.txt4 &†" & Me.[Section/Team] & “ " &
Me.txt4 & “ " & Me.txt6


Where am I going wrong. I am entering this in the Message text

Thanks in advance
 
L

LindaBee

It is in a macro the macro action is SendObject. I have entered the email
address in the To and I have entered a form field in the Subject which works

it is when I am enter this in the Message text of the macro that is when I
get the error message

Wayne-I-M said:
where have you put this code ?

You say its a macro but this looks (sort of) like an onEvent code
Where am I going wrong. I am entering this in the Message text
Where the Message Text ?


--
Wayne
Manchester, England.



LindaBee said:
I have created a mcaro that sends an email to a manager and have inserted the
email address and subject but I would like to insert text from different
fields but when I try either the text does not display or I get an error
message.

Click OK to return to the action argument or conditional expression where
expression appears, and then correct.

=[txt1] â€& Me.Fname& " “ & Me.txt2 & “ “& Me.[LID (IF KNOWN)]& “ “ & Me.txt3
& “ " &Me. [Job Title] & " “ & Me.txt4 &†" & Me.[Section/Team] & “ " &
Me.txt4 & “ " & Me.txt6


Where am I going wrong. I am entering this in the Message text

Thanks in advance
 
W

Wayne-I-M

Hi

Sorry but I'm not to good with macros as don't use them often (other than
autoexec)

It's quite simple to send "stuff" with code - give it a try

1st create the report you want to send
2nd create a form that has (somewhere) the 3 e mail address you want to send
it to (and the CC if you want)


Then use the send object method. If you should search on access help it
will give you a "run though". The code behind the OnClick event would look
something like this

*******
all this goes on 1 line - change the code to the names you have on your form
***********

DoCmd.SendObject acReport, "REPORTNAME", "RichTextFormat(*.rtf)",
Forms!FORMNAME!EMAIL ADDRESS, Forms!FORMNAME!EMAILADDRESS-CC, "", "EMAIL
SUBJECT", "EMAIL CONTENT", False, ""


Notes
"RichTextFormat(*.rtf)" - this would format the report as RTF for Word Doc
but there are other formats such as excel, etc


Forms!FORMNAME!EMAIL ADDRESS - this is the main e mail address the report
will be sent to


Forms!FOEMNAME!EMAILADDRESS-CC - this is used if you want to send a copy of
the report to other address at the same time


"EMAIL SUBJECT" - Insert text between the quotes that you want to apprear in
the Subject line of the email


EMAIL CONTENT" - insert text here that you want to apprear at the top of
the main body of the e mail.
As an example you can use this (on the same line)
"Hi " & [ContactName] & Chr(13) + Chr(10) & Chr(13) +
Chr(10) & "I have sent you this information" & Chr(13) + Chr(10)
&[SomeStuffHere]

The some Stuff Here would be taken from a text box on your form (if you want
- if not then just delete this bit.
The best thing about this is that you can send different messages to
different people - or not - up to you


Hope this helps


--
Wayne
Manchester, England.



LindaBee said:
It is in a macro the macro action is SendObject. I have entered the email
address in the To and I have entered a form field in the Subject which works

it is when I am enter this in the Message text of the macro that is when I
get the error message

Wayne-I-M said:
where have you put this code ?

You say its a macro but this looks (sort of) like an onEvent code
Where am I going wrong. I am entering this in the Message text
Where the Message Text ?


--
Wayne
Manchester, England.



LindaBee said:
I have created a mcaro that sends an email to a manager and have inserted the
email address and subject but I would like to insert text from different
fields but when I try either the text does not display or I get an error
message.

Click OK to return to the action argument or conditional expression where
expression appears, and then correct.

=[txt1] â€& Me.Fname& " “ & Me.txt2 & “ “& Me.[LID (IF KNOWN)]& “ “ & Me.txt3
& “ " &Me. [Job Title] & " “ & Me.txt4 &†" & Me.[Section/Team] & “ " &
Me.txt4 & “ " & Me.txt6


Where am I going wrong. I am entering this in the Message text

Thanks in advance
 
L

LindaBee

Thanks Wayne but I think I was looking for something slightly differnet , but
thanks for trying

Wayne-I-M said:
Hi

Sorry but I'm not to good with macros as don't use them often (other than
autoexec)

It's quite simple to send "stuff" with code - give it a try

1st create the report you want to send
2nd create a form that has (somewhere) the 3 e mail address you want to send
it to (and the CC if you want)


Then use the send object method. If you should search on access help it
will give you a "run though". The code behind the OnClick event would look
something like this

*******
all this goes on 1 line - change the code to the names you have on your form
***********

DoCmd.SendObject acReport, "REPORTNAME", "RichTextFormat(*.rtf)",
Forms!FORMNAME!EMAIL ADDRESS, Forms!FORMNAME!EMAILADDRESS-CC, "", "EMAIL
SUBJECT", "EMAIL CONTENT", False, ""


Notes
"RichTextFormat(*.rtf)" - this would format the report as RTF for Word Doc
but there are other formats such as excel, etc


Forms!FORMNAME!EMAIL ADDRESS - this is the main e mail address the report
will be sent to


Forms!FOEMNAME!EMAILADDRESS-CC - this is used if you want to send a copy of
the report to other address at the same time


"EMAIL SUBJECT" - Insert text between the quotes that you want to apprear in
the Subject line of the email


EMAIL CONTENT" - insert text here that you want to apprear at the top of
the main body of the e mail.
As an example you can use this (on the same line)
"Hi " & [ContactName] & Chr(13) + Chr(10) & Chr(13) +
Chr(10) & "I have sent you this information" & Chr(13) + Chr(10)
&[SomeStuffHere]

The some Stuff Here would be taken from a text box on your form (if you want
- if not then just delete this bit.
The best thing about this is that you can send different messages to
different people - or not - up to you


Hope this helps


--
Wayne
Manchester, England.



LindaBee said:
It is in a macro the macro action is SendObject. I have entered the email
address in the To and I have entered a form field in the Subject which works

it is when I am enter this in the Message text of the macro that is when I
get the error message

Wayne-I-M said:
where have you put this code ?

You say its a macro but this looks (sort of) like an onEvent code

Where am I going wrong. I am entering this in the Message text
Where the Message Text ?


--
Wayne
Manchester, England.



:

I have created a mcaro that sends an email to a manager and have inserted the
email address and subject but I would like to insert text from different
fields but when I try either the text does not display or I get an error
message.

Click OK to return to the action argument or conditional expression where
expression appears, and then correct.

=[txt1] â€& Me.Fname& " “ & Me.txt2 & “ “& Me.[LID (IF KNOWN)]& “ “ & Me.txt3
& “ " &Me. [Job Title] & " “ & Me.txt4 &†" & Me.[Section/Team] & “ " &
Me.txt4 & “ " & Me.txt6


Where am I going wrong. I am entering this in the Message text

Thanks in advance
 
D

Douglas J. Steele

Macros know nothing about the Me keyword. You need Forms![NameOfForm]
instead of Me.
 
L

LindaBee

I have used it in Code instead as follows

Private Sub Command108_Click()
On Error GoTo Err_Command108_Click

Dim SendTo As String, MySubject As String, MyMessage As String
SendTo = "(e-mail address removed)"
MySubject = Me.Fname & " " & Me.Sname
MyMessage = " I have set up " & Fname & " " & Sname & " on lid no" &
LIdNo & " " & " password is xxxxxxxxx nad s/he is " & [JobTitle] & " at " &
Section & " needs adding to following lists xxxxxxxx. Forms signed by" &
Manager & "Please notify Admin when done"
DoCmd.SendObject acSendNoObject, , , SendTo, , , MySubject,
MyMessage, True

Exit_Command108_Click:
Exit Sub

Err_Command108_Click:
MsgBox Err.Description
Resume Exit_Command108_Click

End Sub


Douglas J. Steele said:
Macros know nothing about the Me keyword. You need Forms![NameOfForm]
instead of Me.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


LindaBee said:
I have created a mcaro that sends an email to a manager and have inserted
the
email address and subject but I would like to insert text from different
fields but when I try either the text does not display or I get an error
message.

Click OK to return to the action argument or conditional expression where
expression appears, and then correct.

=[txt1] "& Me.Fname& " " & Me.txt2 & " "& Me.[LID (IF KNOWN)]& " " &
Me.txt3
& " " &Me. [Job Title] & " " & Me.txt4 &" " & Me.[Section/Team] & " " &
Me.txt4 & " " & Me.txt6


Where am I going wrong. I am entering this in the Message text

Thanks in advance
 
S

Stockwell43

Hi Linda,

I assume you have a command button on your form to activate the macro? See
if this is what your looking for: Open the buttons properties menu and go to
the OnClick event and change it from the macro to Event Procedure and click
on the three dots to the right (...) and dump this in:

Private Sub cmdSendEmail_Click()
On Error GoTo eh
Dim SendTo As String, MySubject As String, MyMessage As String
SendTo = ""
MySubject = "Procedure Update"
MyMessage = MyMessage & vbNullString & vbCr & vbCr & "Procedure Number: " &
Me.ProcNumber & vbCrLf & _
vbCr & "Procedure Name: " & Me.ProcName & vbCrLf & _
vbCr & "Effective Date: " & Me.EffDate & vbCrLf & _
vbCr & "Comments: " & vbCr & Me.Comments

DoCmd.SendObject acSendNoObject, , , SendTo, , , MySubject, MyMessage, True

eh:
If Err.Number = 2501 Then
MsgBox "This email message has not been sent. Message has been
cancelled."
End If
End Sub

Under the MyMessage, start with the Me.ProcName and change all the Me's to
the name of your fields and the acutal Name like Procedure Name:, change to
whatever you want it to say to represent the data in the field. I have used
this many times and never had a problem. If you don't need as many field as
in the code just delete, if you need more that copy a section and add.

BE SURE TO MAKE A COPY OF YOUR DATABASE BEFORE YOU DO THIS! Just in case
something gets messed up you have a back up.

Good Luck!!

LindaBee said:
I have used it in Code instead as follows

Private Sub Command108_Click()
On Error GoTo Err_Command108_Click

Dim SendTo As String, MySubject As String, MyMessage As String
SendTo = "(e-mail address removed)"
MySubject = Me.Fname & " " & Me.Sname
MyMessage = " I have set up " & Fname & " " & Sname & " on lid no" &
LIdNo & " " & " password is xxxxxxxxx nad s/he is " & [JobTitle] & " at " &
Section & " needs adding to following lists xxxxxxxx. Forms signed by" &
Manager & "Please notify Admin when done"
DoCmd.SendObject acSendNoObject, , , SendTo, , , MySubject,
MyMessage, True

Exit_Command108_Click:
Exit Sub

Err_Command108_Click:
MsgBox Err.Description
Resume Exit_Command108_Click

End Sub


Douglas J. Steele said:
Macros know nothing about the Me keyword. You need Forms![NameOfForm]
instead of Me.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


LindaBee said:
I have created a mcaro that sends an email to a manager and have inserted
the
email address and subject but I would like to insert text from different
fields but when I try either the text does not display or I get an error
message.

Click OK to return to the action argument or conditional expression where
expression appears, and then correct.

=[txt1] "& Me.Fname& " " & Me.txt2 & " "& Me.[LID (IF KNOWN)]& " " &
Me.txt3
& " " &Me. [Job Title] & " " & Me.txt4 &" " & Me.[Section/Team] & " " &
Me.txt4 & " " & Me.txt6


Where am I going wrong. I am entering this in the Message text

Thanks in advance
 

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