Send email from access - old post re-opened (1 Viewer)

jmsjazz

Registered User.
Local time
Yesterday, 19:33
Joined
Mar 19, 2013
Messages
43
Re: send email from access
Thanks for getting me started on emailing from a form.
My problem is, I have a form called frmINCIDENTS, with a text box (txtemail) which holds the email address to be sent. It sends the information correctly to outlook, but when I click SEND, on returning to Access I get the attached error (3078: Access Database Engine cannot find the table or query)
I do not use a table to store helpdesk tickets; instead how do I change the following to simply return to frmINCIDENTS?

'Set the update statement to disable command button
'once e-mail is sent
strSQL = "UPDATE tblHelpDeskTickets SET tblHelpDeskTickets.ysnTicketAssigned = -1 " & _
"Where tblHelpDeskTickets.lngTicketID = " & Me.txtTicketID & ";"


On Error GoTo Err_Execute
CurrentDb.Execute strSQL, dbFailOnError
On Error GoTo 0

'Requery checkbox to show checked
'after update statement has ran
'and disable send mail command button
Me.chkTicketAssigned.Requery
Me.chkTicketAssigned.SetFocus
Me.cmdMailTicket.Enabled = False

Exit Sub

Thanks!

Just realised CVBOAS' original post is needed to make sense of all this:
send email from access
Hi.
I have created a form to send emails from access, but i want to be the user to establish the date of delivery. For exampel: send today the email but it will only be delivered in the next week. Thanks


I have the this code to send emails:



Private Sub cmdMailTicket_Click()
On Error GoTo Err_cmdMailTicket_Click

Dim stWhere As String '-- Criteria for DLookup
Dim varTo As Variant '-- Address for SendObject
Dim stText As String '-- E-mail text
Dim RecDate As Variant '-- Rec date for e-mail text
Dim stSubject As String '-- Subject line of e-mail
Dim stTicketID As String '-- The ticket ID from form
Dim stWho As String '-- Reference to tblUsers
Dim stHelpDesk As String '-- Person who assigned ticket
Dim strSQL As String '-- Create SQL update statement
Dim errLoop As Error

'-- Combo of names to assign ticket to
stWho = Me.cboAssignee
stWhere = "tblUsers.strUserID = " & "'" & stWho & "'"
'-- Looks up email address from TblUsers
varTo = DLookup("[strEMail]", "tblUsers", stWhere)

stSubject = ":: New Help Desk Ticket ::"

stTicketID = Format(Me.txtTicketID, "00000")
RecDate = Me.txtDateReceived
'-- Helpdesk employee who assigns ticket
strHelpDesk = Me.cboReceivedBy.Column(1)


stText = "You have been assigned a new ticket." & Chr$(13) & Chr$(13) & _
"Ticket number: " & stTicketID & Chr$(13) & _
"This ticket has been assigned to you by: " & strHelpDesk & Chr$(13) & _
"Received Date: " & RecDate & Chr$(13) & Chr$(13) & _
"This is an automated message. Please do not respond to this e-mail."

'Write the e-mail content for sending to assignee
DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, -1

'Set the update statement to disable command button
'once e-mail is sent
strSQL = "UPDATE tblHelpDeskTickets SET tblHelpDeskTickets.ysnTicketAssigned = -1 " & _
"Where tblHelpDeskTickets.lngTicketID = " & Me.txtTicketID & ";"


On Error GoTo Err_Execute
CurrentDb.Execute strSQL, dbFailOnError
On Error GoTo 0

'Requery checkbox to show checked
'after update statement has ran
'and disable send mail command button
Me.chkTicketAssigned.Requery
Me.chkTicketAssigned.SetFocus
Me.cmdMailTicket.Enabled = False

Exit Sub

Err_Execute:

' Notify user of any errors that result from
' executing the query.
If DBEngine.Errors.Count > 0 Then
For Each errLoop In DBEngine.Errors
MsgBox "Error number: " & errLoop.Number & vbCr & _
errLoop.Description
Next errLoop
End If

Resume Next


Exit_cmdMailTicket_Click:
Exit Sub

Err_cmdMailTicket_Click:
MsgBox Err.Description
Resume Exit_cmdMailTicket_Click

End Sub
 
Last edited:

Users who are viewing this thread

Top Bottom