How do I add additional email recipients to the below code in the .To field. I have tried "1st, 2nd,... etc" and "1st", "2nd", ...etc. But both do not work. The code to fire off the emails is located in a module and is called from the main sub module if criteria is met. Any advise would be welcome.
With OutlookMail
.To = "gjenn@myemailaddress.com"
.CC = ""
.BCC = ""
.Subject = "Paul Getty"
.Body = "Paul, Please see attached and advise of parts quantity you are OK to release. "
.Attachments.Add Wb2.FullName
.Send
End With
================================================================
Full code that sends the email below
================================================================
Sub EmailOut1()
'Update 20131209
Dim xFile As String
Dim xFormat As Long
Dim Wb As Workbook
Dim Wb2 As Workbook
Dim Ws As Worksheet
Dim FilePath As String
Dim FileName As String
Dim OutlookApp As Object
Dim OutlookMail As Object
Dim WorkRng As Range
'xTitleId = "Manual_DCI_Selection Paul"
Set WorkRng = Application.Selection ' the common way to refer to the active range Selection
'Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
'Application.ScreenUpdating = False
'Application.DisplayAlerts = False
Set Wb = Application.ActiveWorkbook
Wb.Worksheets.Add
Set Ws = Application.ActiveSheet
WorkRng.Copy Ws.Cells(1, 1)
Range("A1").CurrentRegion.Select
Selection.EntireColumn.AutoFit
Ws.Copy
ActiveSheet.Name = "LinePinchRequest"
Set Wb2 = Application.ActiveWorkbook
Select Case Wb.FileFormat
Case xlOpenXMLWorkbook:
xFile = ".xlsx"
xFormat = xlOpenXMLWorkbook
Case xlOpenXMLWorkbookMacroEnabled:
If Wb2.HasVBProject Then
xFile = ".xlsm"
xFormat = xlOpenXMLWorkbookMacroEnabled
Else
xFile = ".xlsx"
xFormat = xlOpenXMLWorkbook
End If
Case Excel8:
xFile = ".xls"
xFormat = Excel8
Case xlExcel12:
xFile = ".xlsb"
xFormat = xlExcel12
End Select
FilePath = Environ$("temp") & "\"
FileName = Wb.Name & Format(Now, "dd-mmm-yy h-mm-ss")
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)
Wb2.SaveAs FilePath & FileName & xFile, FileFormat:=xFormat
With OutlookMail
.To = "gjenn@mymailaddress.com"
.CC = ""
.BCC = ""
.Subject = "Paul Getty"
.Body = "Paul, Please see attached and advise of parts quantity you are OK to release. "
.Attachments.Add Wb2.FullName
.Send
End With
Wb2.Close
ActiveSheet.Delete
Kill FilePath & FileName & xFile
Set OutlookMail = Nothing
Set OutlookApp = Nothing
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
With OutlookMail
.To = "gjenn@myemailaddress.com"
.CC = ""
.BCC = ""
.Subject = "Paul Getty"
.Body = "Paul, Please see attached and advise of parts quantity you are OK to release. "
.Attachments.Add Wb2.FullName
.Send
End With
================================================================
Full code that sends the email below
================================================================
Sub EmailOut1()
'Update 20131209
Dim xFile As String
Dim xFormat As Long
Dim Wb As Workbook
Dim Wb2 As Workbook
Dim Ws As Worksheet
Dim FilePath As String
Dim FileName As String
Dim OutlookApp As Object
Dim OutlookMail As Object
Dim WorkRng As Range
'xTitleId = "Manual_DCI_Selection Paul"
Set WorkRng = Application.Selection ' the common way to refer to the active range Selection
'Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
'Application.ScreenUpdating = False
'Application.DisplayAlerts = False
Set Wb = Application.ActiveWorkbook
Wb.Worksheets.Add
Set Ws = Application.ActiveSheet
WorkRng.Copy Ws.Cells(1, 1)
Range("A1").CurrentRegion.Select
Selection.EntireColumn.AutoFit
Ws.Copy
ActiveSheet.Name = "LinePinchRequest"
Set Wb2 = Application.ActiveWorkbook
Select Case Wb.FileFormat
Case xlOpenXMLWorkbook:
xFile = ".xlsx"
xFormat = xlOpenXMLWorkbook
Case xlOpenXMLWorkbookMacroEnabled:
If Wb2.HasVBProject Then
xFile = ".xlsm"
xFormat = xlOpenXMLWorkbookMacroEnabled
Else
xFile = ".xlsx"
xFormat = xlOpenXMLWorkbook
End If
Case Excel8:
xFile = ".xls"
xFormat = Excel8
Case xlExcel12:
xFile = ".xlsb"
xFormat = xlExcel12
End Select
FilePath = Environ$("temp") & "\"
FileName = Wb.Name & Format(Now, "dd-mmm-yy h-mm-ss")
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)
Wb2.SaveAs FilePath & FileName & xFile, FileFormat:=xFormat
With OutlookMail
.To = "gjenn@mymailaddress.com"
.CC = ""
.BCC = ""
.Subject = "Paul Getty"
.Body = "Paul, Please see attached and advise of parts quantity you are OK to release. "
.Attachments.Add Wb2.FullName
.Send
End With
Wb2.Close
ActiveSheet.Delete
Kill FilePath & FileName & xFile
Set OutlookMail = Nothing
Set OutlookApp = Nothing
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub