Hi,
Below is my code and it works. But I use the NEW OUTLOOK. The only way i can send the email is to kill the Legacy version of outlook?? Then the email quickly send but if i try to run it again i have to do the same steps killing the app.
Is this a problem with the new outlook?
Sub Financal_Dashoard_Email()
Dim rng As Range
Dim rng2 As Range
Dim rng3 As Range
Dim rng4 As Range
Dim rng5 As Range
Dim rng6 As Range
Dim rng7 As Range
Dim rng8 As Range
Dim OutApp As Object
Dim OutMail As Object
Dim StrBody As String
StrBody = "Hello Team," & "<br>" & "<br>" & _
"Please note NET INCOME is subject to change as not all payables have been entered." & "<br><br>"
Set rng = Nothing
On Error Resume Next
'Only the visible cells in the selection
'Set rng = Selection.SpecialCells(xlCellTypeVisible)
'You can also use a fixed range if you want
Set rng = Sheets("Financal Dashoard").Range("A2:D99").SpecialCells(xlCellTypeVisible)
Set rng2 = Sheets("Financal Dashoard").Range("F1:K99").SpecialCells(xlCellTypeVisible)
Set rng3 = Sheets("Financal Dashoard").Range("O1:Q99").SpecialCells(xlCellTypeVisible)
Set rng4 = Sheets("Financal Dashoard").Range("S1:Y99").SpecialCells(xlCellTypeVisible)
Set rng5 = Sheets("Financal Dashoard").Range("AA1:AE99").SpecialCells(xlCellTypeVisible)
Set rng6 = Sheets("Financal Dashoard").Range("AG1:AK99").SpecialCells(xlCellTypeVisible)
Set rng7 = Sheets("Financal Dashoard").Range("AM1:AS199").SpecialCells(xlCellTypeVisible)
Set rng8 = Sheets("Financal Dashoard").Range("AU1:AU1").SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "gOD@gOD.COM"
'.CC = "G=EGS-IND-SC-Managers" & ";" & Cells(5, 2)
.BCC = ""
.Subject = Format(Now, "ddd MMM dd/yy") & " - Financal Dashoard"
.HTMLBody = StrBody & RangetoHTML(rng) & RangetoHTML(rng2) & _
RangetoHTML(rng3) & RangetoHTML(rng4) & RangetoHTML(rng5) & _
RangetoHTML(rng6) & RangetoHTML(rng7) & RangetoHTML(rng8)
'.Attachments.Add ActiveWorkbook.FullName
'.Display 'or use .Display
.Send
End With
On Error GoTo 0
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Below is my code and it works. But I use the NEW OUTLOOK. The only way i can send the email is to kill the Legacy version of outlook?? Then the email quickly send but if i try to run it again i have to do the same steps killing the app.
Is this a problem with the new outlook?
Sub Financal_Dashoard_Email()
Dim rng As Range
Dim rng2 As Range
Dim rng3 As Range
Dim rng4 As Range
Dim rng5 As Range
Dim rng6 As Range
Dim rng7 As Range
Dim rng8 As Range
Dim OutApp As Object
Dim OutMail As Object
Dim StrBody As String
StrBody = "Hello Team," & "<br>" & "<br>" & _
"Please note NET INCOME is subject to change as not all payables have been entered." & "<br><br>"
Set rng = Nothing
On Error Resume Next
'Only the visible cells in the selection
'Set rng = Selection.SpecialCells(xlCellTypeVisible)
'You can also use a fixed range if you want
Set rng = Sheets("Financal Dashoard").Range("A2:D99").SpecialCells(xlCellTypeVisible)
Set rng2 = Sheets("Financal Dashoard").Range("F1:K99").SpecialCells(xlCellTypeVisible)
Set rng3 = Sheets("Financal Dashoard").Range("O1:Q99").SpecialCells(xlCellTypeVisible)
Set rng4 = Sheets("Financal Dashoard").Range("S1:Y99").SpecialCells(xlCellTypeVisible)
Set rng5 = Sheets("Financal Dashoard").Range("AA1:AE99").SpecialCells(xlCellTypeVisible)
Set rng6 = Sheets("Financal Dashoard").Range("AG1:AK99").SpecialCells(xlCellTypeVisible)
Set rng7 = Sheets("Financal Dashoard").Range("AM1:AS199").SpecialCells(xlCellTypeVisible)
Set rng8 = Sheets("Financal Dashoard").Range("AU1:AU1").SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "gOD@gOD.COM"
'.CC = "G=EGS-IND-SC-Managers" & ";" & Cells(5, 2)
.BCC = ""
.Subject = Format(Now, "ddd MMM dd/yy") & " - Financal Dashoard"
.HTMLBody = StrBody & RangetoHTML(rng) & RangetoHTML(rng2) & _
RangetoHTML(rng3) & RangetoHTML(rng4) & RangetoHTML(rng5) & _
RangetoHTML(rng6) & RangetoHTML(rng7) & RangetoHTML(rng8)
'.Attachments.Add ActiveWorkbook.FullName
'.Display 'or use .Display
.Send
End With
On Error GoTo 0
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub