Hi all,
First up let me thank everyone who is on this forum for thier total commitment to hepling novices myself create functional databases. You have all been a great help over and over again.
However, I now need to ask for assitance again from someone who has the time to help me.
I am trying to create a vba script which I will attach to the on click event of a button. The script will open an email in outlook and populate the 'to' section with a email address pulled from a textbox on a form (which is based on a query called qryClients) and the body of the email would be generated from a free type memo field based on the same form.
I know that there used to be a 'sendobject' command in 2007 which allowed emails but I have searched for this in 2010 and it no longer exists?
Also, I have done a lot of research on this but the code involved looks incredibly complex to me (VBA noob) and would appreciate someone pointing out any obvious cockups ive made as its currently not running.
This is my code:
Private Sub Command12_Click()
Sub GenerateEmail(Recipient As String, subj As String, msg As String, attmt As String)
'Generate email
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = (I am assuming this should point to the text box on the form?
.CC = ""
.BCC = ""
.Subject = "Project Update"
.Body = (as above, pointing to the memo field?)
.Display
.Send
End With
On Error GoTo 0
End Sub
Any help would be very appreciated!!!
First up let me thank everyone who is on this forum for thier total commitment to hepling novices myself create functional databases. You have all been a great help over and over again.
However, I now need to ask for assitance again from someone who has the time to help me.
I am trying to create a vba script which I will attach to the on click event of a button. The script will open an email in outlook and populate the 'to' section with a email address pulled from a textbox on a form (which is based on a query called qryClients) and the body of the email would be generated from a free type memo field based on the same form.
I know that there used to be a 'sendobject' command in 2007 which allowed emails but I have searched for this in 2010 and it no longer exists?
Also, I have done a lot of research on this but the code involved looks incredibly complex to me (VBA noob) and would appreciate someone pointing out any obvious cockups ive made as its currently not running.
This is my code:
Private Sub Command12_Click()
Sub GenerateEmail(Recipient As String, subj As String, msg As String, attmt As String)
'Generate email
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = (I am assuming this should point to the text box on the form?
.CC = ""
.BCC = ""
.Subject = "Project Update"
.Body = (as above, pointing to the memo field?)
.Display
.Send
End With
On Error GoTo 0
End Sub
Any help would be very appreciated!!!