Below will take data from a from and put it in the body of an email. It could
give you some ideas. Watch out for word wrapping.
'Created by: Jerry Whittle
'Created : 12/17/98 8:39:30 AM
Function EmailTextFromForm()
On Error GoTo Err_EmailTextFromForm
Dim rptTo As String
Dim rptCC As String
Dim rptBCC As String
Dim LGQReportName As String
Dim rptSubject As String
Dim rptMessageText As String
rptTo = DLookup("[DpTO]", "EmailAddresses") 'Looks up the email address
from a table
'rptTo = "(e-mail address removed)" 'Hard coded email address
'rptTo = [Forms]![frmACTIVE]![ToEmail] 'Email address taken from the form
rptCC = DLookup("[DpCC]", "EmailAddresses")
'rptCC = "(e-mail address removed)"
rptBCC = DLookup("[LgBCC]", "EmailAddresses")
rptSubject = "Training Line Number Request " & Now
rptMessageText = "Bogie Request from LGQRT" & vbCrLf _
& vbCrLf & "Course: " & vbTab & [Forms]![frmACTIVE]![COURSE] _
& vbCrLf & "Location: " & vbTab & [Forms]![frmACTIVE]![TNGLOC] _
& vbCrLf & "Start Date: " & vbTab & Format([Forms]![frmACTIVE]![CSD],
"Medium Date") _
& vbCrLf & "Grad Date: " & vbTab & Format([Forms]![frmACTIVE]![CGD],
"Medium Date") _
& vbCrLf & "Name: " & vbTab & [Forms]![frmACTIVE]![NAME] _
& vbCrLf & "Grade: " & vbTab & [Forms]![frmACTIVE]![GRADE] _
& vbCrLf & "SSAN: " & vbTab & Format([Forms]![frmACTIVE]![SSAN],
"000-00-0000") _
& vbCrLf & "Losing Base: " & vbTab & [Forms]![frmACTIVE]![CORGLOC] _
& vbCrLf & "Gaining Base: " & vbTab & [Forms]![frmACTIVE]![GORGLOC] _
& vbCrLf & "RNLTD: " & vbTab & Format([Forms]![frmACTIVE]![RNLTD],
"Medium Date") _
& vbCrLf & "TLN: " & vbTab & "Pending"
DoCmd.SendObject acSendNoObject, , acFormatTXT, rptTo, rptCC, rptBCC,
rptSubject, rptMessageText, False, ""
Exit_EmailTextFromForm:
Exit Function
Err_EmailTextFromForm:
Select Case Err
Case 0 'insert Errors you wish to ignore here
Resume Next
Case Else 'All other errors will trap
Beep
MsgBox Error$, , "Error in function modUtility.EmailTextFromForm"
Resume Exit_EmailTextFromForm
End Select
Resume 0 'FOR TROUBLESHOOTING
End Function
--
Jerry Whittle
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
Simon said:
I have a form with a text box that uses visual basic to create a new email
message.
Is it possible to extract information from a query and a table and have it
appear in the message section of the email in text format that can then be
editied.
I realise I could attach a report but I want to avoid attachments as the
data is relatively short.
Any ideas?
I am using Access 2003 and as ever any help most appreciated.