I am trying to design a form to send an email, which I based on a Helpdesk database code I found on the web.
I am not at all confident at writing code, so I may need some help.
This is the code so far:
The error checking stops with the Me.cboFullName line.
The table called Emails has the following fields:
EID, Email, FullName, Subject, Merssage, DateSent, fkName
another table.
The forms record source is the Emails table.
What I want to acheive is to choose the email address and the fullname, I think you should be able to link these fields, but I don't know how, then fill in the rest of the fields and send the email using SendObject.
Can anyone assist me in sorting this out?
Ultimately I would like to send emails to all users, but first things first, I ned to get this working.
I am not at all confident at writing code, so I may need some help.
This is the code so far:
Code:
Private Sub Command12_Click()
Dim stWhere As String
Dim varTo As Variant
Dim stText As String
Dim Sent As Variant
Dim stSubject As String
Dim stWho As String
Dim strSQL As String
Dim errLoop As Error
stWho = Me.cboFullName
stWhere = "tblBT_Emails.strEmail =" & "" & stWho & ""
varTo = DLookup("[EMail]", "tblBT_Emails", stWhere)
stSubject = DLookup("[Subject]", "BT_Emails", "[Subject]" = "&""Forms!BT_Emails!Subject")
Sent = Me.txtDateSent
stText = Me.txtMessage
DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, -1
End Sub
The table called Emails has the following fields:
EID, Email, FullName, Subject, Merssage, DateSent, fkName
another table.
The forms record source is the Emails table.
What I want to acheive is to choose the email address and the fullname, I think you should be able to link these fields, but I don't know how, then fill in the rest of the fields and send the email using SendObject.
Can anyone assist me in sorting this out?
Ultimately I would like to send emails to all users, but first things first, I ned to get this working.