Jaywar2013
New Member
- Joined
- Apr 5, 2013
- Messages
- 23
Hi All
I have a VBA for sending out an email (Below) however I am struggling to think of how to attached a sheet to the same email. The Sheet/Tab I want to attach/send is called 'Send'
Sub SendEmail()Dim OutlookApp As Object
Dim MITem As Object
Dim Cell As Range
Dim Subj As String
Dim EmailAddr As String
Dim Answered As String
Dim Msg As String
Dim GOS As String
Dim CallRangOff As String
Dim NormalOpCall As String
Dim NoSuitable As String
Dim Total As String
Dim Wrap As String
Dim Recipient As String
Dim ATT As String
Dim ASO As String
Dim Signature As String
'Create Outlook object
Set OutlookApp = CreateObject("Outlook.Application")
'Loop through the rows
For Each Cell In _
Columns("c").Cells.SpecialCells(xlCellTypeConstants)
If Cell.Value Like "*@*" Then
'get the data
Subj = "NOC Call Stats " & Cell.Offset(0, 1)
Recipient = Cell.Offset(0, -2).Value
EmailAddr = Cell.Value
Answered = Format(Cell.Offset(0, 2).Value, "0.0%")
GOS = Format(Cell.Offset(0, 3).Value, "0.0%")
CallRangOff = Cell.Offset(0, 4).Value
NormalOpCall = Cell.Offset(0, 5).Value
NoSuitable = Cell.Offset(0, 6).Value
Total = Cell.Offset(0, 7).Value
Wrap = Cell.Offset(0, 8).Value
Wrap = Format(Cell.Offset(0, 8).Value, "0.0")
ATT = Cell.Offset(0, 9).Value
ATT = Format(Cell.Offset(0, 9).Value, "0.0")
ASO = Cell.Offset(0, 10).Value
ASO = Format(Cell.Offset(0, 10).Value, "0.0")
Signature = Cell.Offset(0, -1).Value
'Compose message
Msg = "Dear " & Recipient & vbCrLf & vbCrLf
Msg = Msg & "Please see the attached daily NOC call stats: " & vbCrLf & vbCrLf
Msg = Msg & "Answered = " & Answered & vbCrLf & vbCrLf
Msg = Msg & "Grade of Service = " & GOS & vbCrLf & vbCrLf
Msg = Msg & "Total Calls Offered = " & Total & vbCrLf & vbCrLf
Msg = Msg & "Total Calls Answered = " & NormalOpCall & vbCrLf & vbCrLf
Msg = Msg & "Calls Dropped = " & CallRangOff & vbCrLf & vbCrLf
Msg = Msg & "No Suitable Operator Logged on = " & NoSuitable & vbCrLf & vbCrLf
Msg = Msg & "Average Wrap = " & Wrap & vbCrLf & vbCrLf
Msg = Msg & "Average Talk Time = " & ATT & vbCrLf & vbCrLf
Msg = Msg & "Avg Speed of Answer = " & ASO
Msg = Msg & vbCrLf & vbCrLf & vbCrLf
Msg = Msg & Signature
'Create Mail Item and Send it
Set MITem = OutlookApp.CreateItem(0)
With MITem
.to = EmailAddr
.Subject = Subj
.body = Msg
.Display
End With
End If
Next
End Sub
Any Ideas?
I have a VBA for sending out an email (Below) however I am struggling to think of how to attached a sheet to the same email. The Sheet/Tab I want to attach/send is called 'Send'
Sub SendEmail()Dim OutlookApp As Object
Dim MITem As Object
Dim Cell As Range
Dim Subj As String
Dim EmailAddr As String
Dim Answered As String
Dim Msg As String
Dim GOS As String
Dim CallRangOff As String
Dim NormalOpCall As String
Dim NoSuitable As String
Dim Total As String
Dim Wrap As String
Dim Recipient As String
Dim ATT As String
Dim ASO As String
Dim Signature As String
'Create Outlook object
Set OutlookApp = CreateObject("Outlook.Application")
'Loop through the rows
For Each Cell In _
Columns("c").Cells.SpecialCells(xlCellTypeConstants)
If Cell.Value Like "*@*" Then
'get the data
Subj = "NOC Call Stats " & Cell.Offset(0, 1)
Recipient = Cell.Offset(0, -2).Value
EmailAddr = Cell.Value
Answered = Format(Cell.Offset(0, 2).Value, "0.0%")
GOS = Format(Cell.Offset(0, 3).Value, "0.0%")
CallRangOff = Cell.Offset(0, 4).Value
NormalOpCall = Cell.Offset(0, 5).Value
NoSuitable = Cell.Offset(0, 6).Value
Total = Cell.Offset(0, 7).Value
Wrap = Cell.Offset(0, 8).Value
Wrap = Format(Cell.Offset(0, 8).Value, "0.0")
ATT = Cell.Offset(0, 9).Value
ATT = Format(Cell.Offset(0, 9).Value, "0.0")
ASO = Cell.Offset(0, 10).Value
ASO = Format(Cell.Offset(0, 10).Value, "0.0")
Signature = Cell.Offset(0, -1).Value
'Compose message
Msg = "Dear " & Recipient & vbCrLf & vbCrLf
Msg = Msg & "Please see the attached daily NOC call stats: " & vbCrLf & vbCrLf
Msg = Msg & "Answered = " & Answered & vbCrLf & vbCrLf
Msg = Msg & "Grade of Service = " & GOS & vbCrLf & vbCrLf
Msg = Msg & "Total Calls Offered = " & Total & vbCrLf & vbCrLf
Msg = Msg & "Total Calls Answered = " & NormalOpCall & vbCrLf & vbCrLf
Msg = Msg & "Calls Dropped = " & CallRangOff & vbCrLf & vbCrLf
Msg = Msg & "No Suitable Operator Logged on = " & NoSuitable & vbCrLf & vbCrLf
Msg = Msg & "Average Wrap = " & Wrap & vbCrLf & vbCrLf
Msg = Msg & "Average Talk Time = " & ATT & vbCrLf & vbCrLf
Msg = Msg & "Avg Speed of Answer = " & ASO
Msg = Msg & vbCrLf & vbCrLf & vbCrLf
Msg = Msg & Signature
'Create Mail Item and Send it
Set MITem = OutlookApp.CreateItem(0)
With MITem
.to = EmailAddr
.Subject = Subj
.body = Msg
.Display
End With
End If
Next
End Sub
Any Ideas?