hi,
i'm trying to get our call answering screen to generate an email containing record details when a button is clicked on a form. i've managed to get everything working how i want it by looking at and pinching bits of code from around the web, apart from the cc and bcc.
basically, the form is full of labels containing the names of recipients, when the user clicks the label, that persons email address populates the to box. then a button is clicked to prepare the email and the addresses are copied from the text boxes into the email along with the body which is stored in a series of text boxes on the form.
this is the code i'm using.
currently the cc and bcc lines give me error 440 - the object does not support this method.
i've tried aEmail.CC.Add and aEmail.Bcc.Add also and it gives error 424 - object required.
Any help you guys can give will be greatly appreciated.
Thanks
Wayne
i'm trying to get our call answering screen to generate an email containing record details when a button is clicked on a form. i've managed to get everything working how i want it by looking at and pinching bits of code from around the web, apart from the cc and bcc.
basically, the form is full of labels containing the names of recipients, when the user clicks the label, that persons email address populates the to box. then a button is clicked to prepare the email and the addresses are copied from the text boxes into the email along with the body which is stored in a series of text boxes on the form.
this is the code i'm using.
Code:
Private Sub cmd_prepemail_Click()
Dim aOutlook As Object
Dim aEmail As Object
Set aOutlook = CreateObject("Outlook.Application")
Set aEmail = aOutlook.CreateItem(0)
'set Importance
'aEmail.Importance = 2
'Set Subject
aEmail.Subject = "New Message:"
'Set Body for mail
aEmail.Body = "New Message" & vbNewLine & vbNewLine & _
"You have recieved a new message from " & Me.txt_callername.Value & " at " & Me.txt_company.Value & " . Please find the details below." & vbNewLine & vbNewLine _
& "Date & Time of call - " & Me.txt_dateandtime.Value & vbNewLine & vbNewLine _
& "Name of caller - " & Me.txt_callername.Value & vbNewLine & vbNewLine _
& "Company - " & Me.txt_company.Value & vbNewLine & vbNewLine _
& "Telephone Number - " & Me.txt_callertelephone.Value & vbNewLine & vbNewLine _
& "E-Mail Address - " & Me.txt_email.Value & vbNewLine & vbNewLine _
& "Reason For Call - " & Me.txt_reason.Value & vbNewLine & vbNewLine _
& vbNewLine & "Kind Regards."
'Set attachment
'aEmail.ATTACHMENTS.Add ActiveWorkbook.FullName
'Set Recipient
aEmail.Recipients.Add Me.txt_to.Value
aEmail.CC Me.txt_cc.Value
aEmail.BCC Me.txt_bcc.Value
'.display shows the email ready for sending, .send sends the email with no further interactions
aEmail.Display
'blank the recipient text boxes
Me.txt_to.Value = ""
Me.txt_cc.Value = ""
Me.txt_bcc.Value = ""
End Sub
i've tried aEmail.CC.Add and aEmail.Bcc.Add also and it gives error 424 - object required.
Any help you guys can give will be greatly appreciated.
Thanks
Wayne