Emailing with field name in body of email

G

Guest

Hello!

I have a small issue I hope. Below is the code I use for sending an email
from an Access form. It's works great and does excatly what I want it to do
except for one thing; I would like for the Field name to show in the email.
Currently, I am getting the information that is in the field but I also want
to capture the name of the field the information is coming from. Any help
would be appreciated!!

Thanks!!!

Code:

Private Sub cmdSendEmail_Click()
On Error GoTo EH
Dim SendTo As String, MySubject As String, MyMessage As String
SendTo = ""
MySubject = "Procedure Update"
MyMessage = Me.ProcNumber & vbCr & Me.ProcName & vbCr & Me.EffDate & _
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
 
D

Douglas J. Steele

It's not clear to me what Field name it is you're trying to get. Currently,
your message contains the value contained in 4 different controls on your
form. Which field name is it you want?
 
G

Guest

Hi Doug,

Sorry about that. The field names are:

Procedure Number, Procedure Name, Effective Date and Comments.

Thanks!!
 
J

James

How about the following
MyMessage = "Procedure No: " & Me.ProcNumber & vbCr & "Procedure Name:
"& Me.ProcName & vbCr & "Effective Date: " & Me.EffDate & vbCr &
"Comments: " & Me.Comments

Haven't tested this by the way
 
D

Douglas J. Steele

So are you saying you want the name of the field for each of the 4 values?

What about something like:

MyMessage = "Procedure Number: " & Me.ProcNumber & vbCrLf & _
"Procedure Name: " & Me.ProcName & vbCrLf & _
"Effective Date: " & Me.EffDate & vbCrLf & _
"Comments: " & Me.Comments
 
G

Guest

That was absolutely perfect! Just what I was looking for. Thank you so much
for help Doug, I really appreciate it!!
 
G

Guest

Hi James,

Works perfect! Thank you very much for your help, it was most appreciated!!
 

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

Similar Threads

How to CC in an email 9
BCC Email 3
Email Issue 1
Email problem 5
SendObject Email 2
Email fro FORM 4
Emailing information about a specific record 4
Error on sending email 2

Top