Hi,
I have a workbook containing multiple sheets. I have figured out a way to send the entire workbook as an email attachment in Outlook. it works great.
What I need to do now is send just one sheet named ICIMS from the workbook as a CSV file attachment. Any ideas?
Here's what I have so far:
Sub Mail_small_Text_Outlook2()
If Range("c157").Value = "" Or Range("c159").Value = "" Then
MsgBox "Please complete all required fields"
Exit Sub
End If
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "Title: " & Sheet1.Range("A4") & vbNewLine & _
"Department: " & Sheet1.Range("C4") & vbNewLine & _
"SBU: " & Sheet1.Range("B5") & vbNewLine & _
"Level: " & Sheet1.Range("B6") & vbNewLine & _
"Manager: " & Sheet1.Range("B145")
On Error Resume Next
With OutMail
.To = "name.lastname@institution.edu"
.cc = ""
.BCC = ""
.Subject = "Successful Submission: " & Sheet1.Range("a4")
.Body = strbody
.Attachments.Add ActiveWorkbook.FullName
'You can add a file like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
I have a workbook containing multiple sheets. I have figured out a way to send the entire workbook as an email attachment in Outlook. it works great.
What I need to do now is send just one sheet named ICIMS from the workbook as a CSV file attachment. Any ideas?
Here's what I have so far:
Sub Mail_small_Text_Outlook2()
If Range("c157").Value = "" Or Range("c159").Value = "" Then
MsgBox "Please complete all required fields"
Exit Sub
End If
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "Title: " & Sheet1.Range("A4") & vbNewLine & _
"Department: " & Sheet1.Range("C4") & vbNewLine & _
"SBU: " & Sheet1.Range("B5") & vbNewLine & _
"Level: " & Sheet1.Range("B6") & vbNewLine & _
"Manager: " & Sheet1.Range("B145")
On Error Resume Next
With OutMail
.To = "name.lastname@institution.edu"
.cc = ""
.BCC = ""
.Subject = "Successful Submission: " & Sheet1.Range("a4")
.Body = strbody
.Attachments.Add ActiveWorkbook.FullName
'You can add a file like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub