MADELEINECHAPMAN
New Member
- Joined
- May 26, 2021
- Messages
- 2
- Office Version
- 2019
- Platform
- Windows
Hi Everyone,
I am trying to create a VB with very little VB experience.
I would like the VB to create an email for each different email address that is on “sheet 1” with the data relating to their customer code if it has a ‘x’ in the send price advice code column.
Each email would need to show as per the below but would change pending on their customer code and the pricing that is showing on ‘sheet 1’
My current VB reads :
Sub SendEm()
Dim i As Integer, Mail_Object, Email_Subject, o As Variant, lr As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
Set Mail_Object = CreateObject("Outlook.Application")
For i = 2 To lr
With Mail_Object.CreateItem(o)
.Subject = Range("emailB1").Value
.To = Range("emailB2" & i).Value
.Body = Range("emailB3:I16").Value
'.Send
.display 'disable display and enable send to send automatically
End With
Next i
MsgBox "E-mail successfully sent", 64
Application.DisplayAlerts = False
Set Mail_Object = Nothing
End Sub
Can VB do this or should I be looking at a different program?
I appreciate any support or advise.
Thank you.
Sheet 1
Excel Email:
What email should look like
I am trying to create a VB with very little VB experience.
I would like the VB to create an email for each different email address that is on “sheet 1” with the data relating to their customer code if it has a ‘x’ in the send price advice code column.
Each email would need to show as per the below but would change pending on their customer code and the pricing that is showing on ‘sheet 1’
My current VB reads :
Sub SendEm()
Dim i As Integer, Mail_Object, Email_Subject, o As Variant, lr As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
Set Mail_Object = CreateObject("Outlook.Application")
For i = 2 To lr
With Mail_Object.CreateItem(o)
.Subject = Range("emailB1").Value
.To = Range("emailB2" & i).Value
.Body = Range("emailB3:I16").Value
'.Send
.display 'disable display and enable send to send automatically
End With
Next i
MsgBox "E-mail successfully sent", 64
Application.DisplayAlerts = False
Set Mail_Object = Nothing
End Sub
Can VB do this or should I be looking at a different program?
I appreciate any support or advise.
Thank you.
Sheet 1
Excel Email:
What email should look like