[COLOR=#0000ff]Sub[/COLOR] Mail_workbook_Outlook_1()
[COLOR=#0000ff] Dim [/COLOR]OutApp [COLOR=#0000ff]As Object[/COLOR]
[COLOR=#0000ff]Dim[/COLOR] OutMail [COLOR=#0000ff]As Object[/COLOR]
[COLOR=#0000ff] Dim[/COLOR] EmailArr [COLOR=#0000ff]As Variant[/COLOR]
[COLOR=#0000ff] Dim[/COLOR] RowEnd [COLOR=#0000ff] As Integer[/COLOR]
[COLOR=#0000ff]Dim[/COLOR] RowStart [COLOR=#0000ff]As Integer[/COLOR]
[COLOR=#0000ff] Dim [/COLOR]BCCString [COLOR=#0000ff] As String[/COLOR]
[B][COLOR=#ff0000] Dim ApprRejQues As String[/COLOR][/B]
[B][COLOR=#ff0000]ApprRejQues = MsgBox("If You would like to send emails click Yes otherwise click No", vbYesNo, "Email Distribution Prompt")
If ApprRejQues = vbYes Then[/COLOR][/B]
[COLOR=#0000ff] Set[/COLOR] OutApp = CreateObject("Outlook.Application")
[COLOR=#0000ff]Set[/COLOR] OutMail = OutApp.CreateItem(0)
[B][COLOR=#ff0000] RowStart = 2 [/COLOR][/B][COLOR=#008000]'Assumes Header is Present[/COLOR]
RowEnd = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row [COLOR=#008000]'Find last Row in column A with data[/COLOR]
EmailArr = Range(Cells(RowStart, 1), Cells(RowEnd, 1)) [COLOR=#008000]'Define Dynamic Array[/COLOR]
[COLOR=#0000ff]On Error Resume Next [/COLOR] [COLOR=#008000] 'Supress Errors[/COLOR]
[B][COLOR=#ff0000] For i = 1 To RowEnd - 1[/COLOR][/B]
[COLOR=#ff0000][B] If i <> RowEnd - 1 Then[/B][/COLOR]
BCCString = BCCString & EmailArr(i, 1) & "; "[COLOR=#008000] 'Add Semicolon onto email string (BCCString)[/COLOR]
[COLOR=#0000ff] Else[/COLOR]
BCCString = BCCString & EmailArr(i, 1) [COLOR=#008000]'Do not add Semicolon to last email address[/COLOR]
[COLOR=#0000ff] End If[/COLOR]
[COLOR=#0000ff] Next[/COLOR] i
[COLOR=#0000ff] With [/COLOR]OutMail
[B][COLOR=#ff0000] .Display [/COLOR][/B] [COLOR=#008000]'Makes Outlook Mail Visible[/COLOR]
.To = "" [COLOR=#008000]'Add To as necessary[/COLOR]
.CC = "" [COLOR=#008000] 'Add CC as necessary[/COLOR]
.BCC = BCCString
.Subject = "This is the Subject line"
.Body = "This is the Email Body"
[B][COLOR=#ff0000] '.Send [/COLOR][/B][COLOR=#008000]'This line of code has been commented out so the email is not sent[/COLOR]
[COLOR=#0000ff] End With[/COLOR]
[COLOR=#0000ff] On Error GoTo 0[/COLOR] [COLOR=#008000]'Reset Error Handling[/COLOR]
[B][COLOR=#ff0000] Else
MsgBox "No Emails Will Be Sent!!", vbCritical, "Email Distribution Aborted"
Exit Sub
End If[/COLOR][/B][COLOR=#0000ff]
[/COLOR]
[COLOR=#008000] 'Clear Memory
[/COLOR] [B][COLOR=#ff0000] ApprRejQues = vbNullString[/COLOR][/B]
BCCString = vbNullString
[COLOR=#0000ff]Set [/COLOR]OutMail = [COLOR=#0000ff]Nothing[/COLOR]
[COLOR=#0000ff] Set[/COLOR] OutApp = [COLOR=#0000ff]Nothing[/COLOR]
EmailArr = [COLOR=#0000ff]Empty[/COLOR]
RowEnd = [COLOR=#0000ff]Empty[/COLOR]
RowStart = [COLOR=#0000ff]Empty[/COLOR]
[COLOR=#0000ff]End Sub[/COLOR]