picklechips
New Member
- Joined
- Jun 22, 2018
- Messages
- 21
Hi long time lurker 1st time poster.
I would like to send an outlook email to a list of email addresses in column A (first email address starts in cell a2). Each email should have 100 addresses in the "to", then another email creates with the next 100 addresses. Emails should create until until all addresses have been put into emails.
Below is what I have so far which opens an email and puts all the addressees from Column A into one email. I've looked through previous posts but could not figure out how to revise my "EmailTo" and using the "for/next" criterias
Thanks in advance all you ExcelMVPs!
Pickles
I would like to send an outlook email to a list of email addresses in column A (first email address starts in cell a2). Each email should have 100 addresses in the "to", then another email creates with the next 100 addresses. Emails should create until until all addresses have been put into emails.
Below is what I have so far which opens an email and puts all the addressees from Column A into one email. I've looked through previous posts but could not figure out how to revise my "EmailTo" and using the "for/next" criterias
Thanks in advance all you ExcelMVPs!
Pickles
Code:
Option Explicit
Function GetBoiler(ByVal sFile As String) As String
Dim fso As Object, ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function
Sub Emailtest()
Dim SigString As String
Dim SigName As String
Dim Signature As String
Dim OutApp As Object
Dim OutMail As Object
Dim EmailTo As String
Dim Ratesheetpdf As Variant
Dim subj As String
Dim body As String
Dim Lastrw As Long
Ratesheetpdf = Application.GetOpenFilename("PDF Files (*.pdf), *.pdf")
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
'Get the text that will go on the subject
subj = Sheets(1).Range("b2")
'Get the text that will go on the body
body = ActiveWorkbook.Sheets(1).Range("c2")
'add signature
SigName = Sheets(1).Range("d2")
SigString = Environ("appdata") & _
"\Microsoft\Signatures\" & SigName & ".htm"
MsgBox SigString
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
Lastrw = Range("A" & Rows.Count).End(xlUp).Row
EmailTo = Join(Application.Transpose(Sheets(1).Range("a2:a" & Lastrw).Value), ";")
With OutMail
.To = EmailTo
.CC = ""
.BCC = ""
.subject = subj
'.body = body
.htmlbody = body & vbNewLine & vbNewLine & Signature
.Attachments.Add Ratesheetpdf
.Display
'.send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub