Patriot2879
Well-known Member
- Joined
- Feb 1, 2018
- Messages
- 1,259
- Office Version
- 2010
- Platform
- Windows
Hello, good afternoon, please can you help me with the code below it is coming up as an error when i click my email button, the code is this part 'RangetoHTML' from the first line below , hope you can help me please.
This is the whole code below:
HTML:
aEmail.HTMLBody = StrBody & RangetoHTML(rngDataToEmail) & StrThanks
This is the whole code below:
HTML:
Private Sub CommandButton1_Click()
Const PR_SECURITY_FLAGS = "http://schemas.microsoft.com/mapi/proptag/0x6E010003"
Dim aOutlook As Object
Dim aEmail As Object
Dim ulFlags As Integer
Dim rngeAddresses As Range, rngeCell As Range, strRecipients As String
Dim rngDataToEmail As Range
Dim StrBody As String
Set aOutlook = CreateObject("Outlook.Application")
Set aEmail = aOutlook.CreateItem(0)
LastRow = Sheets("Filter").Columns("B:K").Cells.Find(What:="*", LookIn:=xlValues, SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
Set rngDataToEmail = Sheets("Filter").Range("B10:K" & LastRow).SpecialCells(xlCellTypeVisible)
ulFlags = ulFlags Or &H1 ' SECFLAG_ENCRYPTED
aEmail.PropertyAccessor.SetProperty PR_SECURITY_FLAGS, (ulFlags)
StrBody = "******>" & _
"Hi " & Me.TextBox35.Value & "
" & _
"" & Me.TextBox33.Value & "
" & _
"" & Me.TextBox17.Value & "
" & _
"" & _
"" & _
"" & _
"" & _
"" & _
"" & _
"" & _
"" & _
"" & _
"" & _
"" & _
"" & _
"" & _
"Date:" & Me.TextBox18.Text & "" & Me.TextBox19.Text & "" & Me.TextBox21.Text & "" & Me.TextBox23.Text & "" & Me.TextBox25.Text & "" & Me.TextBox26.Text & "Area:" & Me.TextBox9.Value & "" & Me.TextBox20.Value & "" & Me.TextBox22.Value & "" & Me.TextBox24.Value & "" & Me.TextBox29.Value & "" & Me.TextBox30.Value & "" & _
""
StrThanks = "******>" & _
"
" & _
"Many Thanks
" & _
"Complex Team
" & _
""
aEmail.Recipients.Add (UserForm1.TextBox36.Value)
aEmail.CC = (UserForm1.TextBox37.Value)
aEmail.BCC = ""
aEmail.Subject = "Weekly " & Range("D2").Value & (UserForm1.TextBox39.Value)
aEmail.HTMLBody = StrBody & RangetoHTML(rngDataToEmail) & StrThanks
aEmail.Display
Unload Me
End Sub
Last edited: