Please Help!
I included a code for send emails on button click with multiple cell values which comes in column A and B. These column are selected using dynamically generated checkboxes.
I’m able to create dynamic checkboxes but I failed to retrieve the cell values to a variable.
While I’m running the code debugger is giving a message "Run-time error '424': Object required".
I’m a beginner in excel vba. Please help me.
Any help much appreciated as ever!
Thanks
I included a code for send emails on button click with multiple cell values which comes in column A and B. These column are selected using dynamically generated checkboxes.
I’m able to create dynamic checkboxes but I failed to retrieve the cell values to a variable.
While I’m running the code debugger is giving a message "Run-time error '424': Object required".
I’m a beginner in excel vba. Please help me.
Code:
Sub previewmails()
Dim counter As Integer
Dim strSku As Long
Dim Mail As New Message
Dim Config As Configuration
Set Config = Mail.Configuration
If chkbx.Value = 1 Then
counter = 1
For r = 1 To counter
If Cells(r, 1).Top = chkbx.Top Then
counter = counter + 1
strSku = Cells(Target.row, "B").Value & " (" & Cells(Target.row, "A").Value & "), "
Exit For
End If
Next r
End If
Config(cdoSendUsingMethod) = cdoSendUsingPort
Config(cdoSMTPServer) = "smtp.gmail.com"
Config(cdoSMTPServerPort) = 465
Config(cdoSMTPAuthenticate) = cdoBasic
Config(cdoSMTPUseSSL) = True
Config(cdoSendUserName) = "test@mail.com"
Config(cdoSendPassword) = "password@123"
Config.Fields.Update
Mail.To = "test@mail.com"
Mail.From = Config(cdoSendUserName)
Mail.Subject = "Email Subject"
Mail.HTMLBody = "<b>" & strSku & "</b>"
On Error Resume Next
Mail.Send
If Err.Number <> 0 Then
MsgBox Err.Description, vbCritical, "There was an error"
Exit Sub
End If
MsgBox "Your email has been sent!", vbInformation, "Sent"
End Sub
Any help much appreciated as ever!
Thanks