Hello all, I am trying to send an email with all things I must change to my car. In row A I have the condition (yes or no).
So if cell value in row A (I set range A2:A4 for now) is "yes" then the code sends an email to a specific mailbox with text from cell B2.
The excel looks like this:
A B
Implement change Change description
yes change tires
no change oil
yes change filters
What I did so far:
Sub Button1_Click()
Dim r As Range
Dim cell As Range
Set r = Range("A2:A4")
For Each cell In r
If cell.Value = "yes" Then
Dim Email_Subject, Email_Send_From, Email_Send_To, _
Email_Cc, Email_Bcc, Email_Body As String
Dim Mail_Object, Mail_Single As Variant
Email_Subject = "subject"
Email_Send_From = "----"
Email_Send_To = "----"
Email_Body = Range("B2")
On Error GoTo debugs
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Subject = Email_Subject
.To = Email_Send_To
.Body = Email_Body
.send
End With
End If
Next
Exit Sub
debugs:
If Err.Description <> "" Then MsgBox Err.Description
End Sub
the code as it is only writes me an email with only text from cell B2 -> Email_Body = Range("B2")
My blocking point is, I want all values from column B, not just one value, any suggestions what should I put instead Email_Body = Range("B2"),
Thank you.
Bookmarks