0
votes

I was wondering if anyone can help me. I'm currently making an access 2010 DB which has the function to send tickets to other people. I used the template provided by Access, which has the function to email the ticket to whom is it assigned to. Which is great. BUT I can't figure out how to get more than just the TITLE field in the body of the email.

I would like to have a body of text and a few more fields from the ticket if possible? Can anyone help me out?

I've converted the OnClick macro to VBA which I've pasted below. How do I change this to do what I want?

Option Compare Database

'------------------------------------------------------------
' Macro1
'
'------------------------------------------------------------
Function Macro1()
    On Error GoTo Macro1_Err

    With CodeContextObject
        On Error Resume Next
        DoCmd.SendObject , "", "", DLookup("[E-mail Address]", "Contacts", "[ID]=" & Nz(.[Assigned To], 0)), "", "", "Duplicate for your attention", IIf(.Form.Description.TextFormat = 1, PlainText(.Title), .Title), True, ""
        If (.MacroError.Number <> 0) Then
            Beep
            MsgBox .MacroError.Description, vbOKOnly, ""
        End If
    End With


Macro1_Exit:
    Exit Function

Macro1_Err:
    MsgBox Error$
    Resume Macro1_Exit

End Function
1
The code you have is for sending a database object to a mail address - is that what you are trying to do? If so, for the parameter where you are proving the "Title", just include more info. I.E. ", MyTitle & vbcrlf & "Today is ...." & vbcrlf & "Last Line" - Wayne G. Dunn

1 Answers

0
votes

I ones found this on the internet and used it for my ticketsystem: the varbody value contains the messagetext

Private Sub Command430_Click()

On Error GoTo ErrorHandler

Dim varName As Variant
Dim varCC As Variant
Dim varSubject As Variant
Dim varBody As Variant

varName = DLookup("[E-mail Address]"
'separate each email by a ','

varSubject = "Project " & [Forms]![Yourform]![Projectnr] & " contains a new ticket"
'Email subject

varBody = "Please pick up the following ticketnumer: " & [Forms]![Yourform]![Ticketnr]

'Body of the email
DoCmd.SendObject , , , varName, varCC, , varSubject, varBody, True, False
'Send email command. The True after "varBody" allows user to edit email before sending.
'The False at the end will not send it as a Template File

ErrorHandler:
    Select Case Err.Number
    Case 2501
    MsgBox ("No email send")
    End Select

End Sub