B
Bruce
I have tried to research this and I can not find much.
Here is the code I have. It still sends from the defualt account. I have 21
email accounts and this is to be sending from the 21st account. I in the
below code, I have tried using from the 3r account.
Sub Mail_Selection_Range_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2007
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set rng = Nothing
On Error Resume Next
'Only the visible cells in the selection
'Set rng = Selection.SpecialCells(xlCellTypeVisible)
'You can also use a range if you want
Set rng =
Sheets("Invoice").Range("B7:I47").SpecialCells(xlCellTypeVisible)
emailname = Range("M21").Value
bbcname = "(e-mail address removed)"
MsgBox emailname
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
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = emailname
.CC = ""
.BCC = bbcname
.Subject = "Invoice for - " & Range("L6").Value & " - " &
Application.Text(Range("L4").Value, "mmm-dd-yyyy")
.HTMLBody = RangetoHTML(rng)
.Send 'or use .Display
.SendUsingAccount = OutApp.Accounts(3)
End With
On Error GoTo 0
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Here is the code I have. It still sends from the defualt account. I have 21
email accounts and this is to be sending from the 21st account. I in the
below code, I have tried using from the 3r account.
Sub Mail_Selection_Range_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2007
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set rng = Nothing
On Error Resume Next
'Only the visible cells in the selection
'Set rng = Selection.SpecialCells(xlCellTypeVisible)
'You can also use a range if you want
Set rng =
Sheets("Invoice").Range("B7:I47").SpecialCells(xlCellTypeVisible)
emailname = Range("M21").Value
bbcname = "(e-mail address removed)"
MsgBox emailname
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
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = emailname
.CC = ""
.BCC = bbcname
.Subject = "Invoice for - " & Range("L6").Value & " - " &
Application.Text(Range("L4").Value, "mmm-dd-yyyy")
.HTMLBody = RangetoHTML(rng)
.Send 'or use .Display
.SendUsingAccount = OutApp.Accounts(3)
End With
On Error GoTo 0
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub