Hi All,
Wonder if it's possible? I have code that generates multiple emails based on a table, but I am trying to modify the code so that the message body shows the contents of particular column on different lines for each associated email address
So the message body would look like the below
Dan Hardy (Column B),
Line of customisable text within code
Sunday 22 Nov 2015 - OFF (Column D)
Monday 23 Nov 2015 - IN (Column E)
Tuesday 24 Nov 2015 - IN (Column F)
Wednesday 25 Nov 2015 - IN (Column G)
Thursday 26 Nov 2015 - IN (Column H)
Friday 27 Nov 2015 - IN (Column I)
Saturday 28 Nov 2015 - IN (Column J)
Line of customisable text within code
the code I have is below
Private Sub CommandButton1_Click()
On Error Resume Next
Dim objOutlook As Object
Dim objMail As Object
Dim rngEntry As Range
Dim rngEntries As Range
Dim sMsgBody As String
Set objOutlook = CreateObject("Outlook.Application")
Set rngEntries = ActiveSheet.Range("C3:C102")
For Each rngEntry In rngEntries
If rngEntry.Value = "" Then GoTo Skip
If rngEntry.Value = "0" Then GoTo Skip
Set objMail = objOutlook.CreateItem(0)
With objMail
.To = rngEntry.Value
.Subject = "Confirmed Working Pattern for NEXT WEEK"
sMsgBody = "Hi," & vbCr & vbCr
sMsgBody = sMsgBody & "Please " & vbCr & vbCr
sMsgBody = sMsgBody & "Remember " & vbCr & vbCr
sMsgBody = sMsgBody & "Notes " & vbCr & vbCr
.Body = sMsgBody
.display
End With
Skip:
Next rngEntry
Set objOutlook = Nothing
Set objMail = Nothing
Set rngEntry = Nothing
Set rngEntries = Nothing
I have attached the file as well if it makes it easier to understand, it may well be a simple solution but the ones that I am trying are just creating blank emails
Thanks in Advance
Danny
Bookmarks