VBA bulk email but based on duplicate email addresses

aj1st

New Member
Joined
Jul 17, 2014
Messages
6
For some reason this code does not populate the text from the column and I am trying to create a loop where if the row has the same email address then it will populate one email instead sending out multiple emails for the same entity.


Option Explicit


Sub SendcomplexEmailHTML()


'early binding

Dim olApp As Outlook.Application
Dim olEmail As Outlook.MailItem
Dim Source As Rangevvvvvvvvvvv

Application.DisplayAlerts = False

Set olApp = New Outlook.Application
Set olEmail = olApp.CreateItem(olMailItem)

With olEmail
.bodyFormat = olFormatHTML
.Display

.HTMLBody = GetHeadHTML & "<p>Dear Sir (s)</p><br><br>" & _
GetMovieDataHTML & .HTMLBody & "</body>"

'.Attachments.Add ""
.To = "aj1st@hotmail.com"

.subject = "Movie Report"
'.Send
End With

End Sub


Function GetMovieDataHTML() As String
Dim FilmColumn As Range, FilmRow As Range, r As Range, c As Range
Dim str As String


Sheet1.Activate
Set FilmColumn = Range("A2", Range("A1").End(xlDown))

str = "<table>"

For Each r In FilmColumn

str = str & "<tr>"

Set FilmRow = Range(r, r.End(xlToRight))

For Each c In FilmRow
str = str & "<td>" & c.Value & "</td>"

Next c
str = str & "</tr>"

Next r

str = str & "</table>"




GetMovieDataHTML = str

End Function


Function GetHeadHTML() As String




Dim str As String

str = "<head><style>" & vbNewLine
str = str & "p {colour:blue;font-family:calibri;font-size:12px;}" & vbNewLine
str = str & "table{colour:blue;font-family:calibri;font-size:12px;border:2px solid blue;}" & vbNewLine
str = str & "</style></head>******>"
GetHeadHTML = str
End Function
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,225,759
Messages
6,186,864
Members
453,380
Latest member
ShaeJ73

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top