I wrote this macro to send emails with a click of a button.
But I have a couple of things that I need help on.
1) The code contains a Table that is created with .HTMLbody, everything is fine, except for the second cell of the last row. The Range("F14").Value gets the Time in a Text Format, which makes 5:30 PM look like 0.729166666666667 when the email is displayed.
2) There are certain Cell Ranges on the sheet (H19:H48), (B51:B55) & (H51:H55), which can either contain a Regular TEXT (remarks that are written manually), or “NA” or “ - ”. I need a macro that would exclude “NA” & “-“ and pull only the Regular Text (remarks) and list them vertically in a numerical order in the email body eg: 1)…2)… vertically**
3) Lastly I need the second code integrated into this First Macro, so it could paste the image of the sheet in the email body as well after the remarks are listed.
But I have a couple of things that I need help on.
1) The code contains a Table that is created with .HTMLbody, everything is fine, except for the second cell of the last row. The Range("F14").Value gets the Time in a Text Format, which makes 5:30 PM look like 0.729166666666667 when the email is displayed.
2) There are certain Cell Ranges on the sheet (H19:H48), (B51:B55) & (H51:H55), which can either contain a Regular TEXT (remarks that are written manually), or “NA” or “ - ”. I need a macro that would exclude “NA” & “-“ and pull only the Regular Text (remarks) and list them vertically in a numerical order in the email body eg: 1)…2)… vertically**
3) Lastly I need the second code integrated into this First Macro, so it could paste the image of the sheet in the email body as well after the remarks are listed.
VBA Code:
Sub DisplayEmail()
Dim emailApplication As Object
Dim emailItem As Object
Set emailApplication = CreateObject("Outlook.Application")
Set emailItem = emailApplication.CreateItem(0)
With emailItem
.To = Range("F5").Value
.CC = Range("K2").Value
.Subject = "Quality Audit and Feedback | Audit ID: " & Range("F3").Value
.Body = "Hi " & Range("Q4").Value & "," & vbNewLine & vbNewLine & "Below is the snapshot of your audit." & vbNewLine & vbNewLine & "Please reach out for any clarification."
.HTMLBody = "Hi " & Range("Q4").Value & "," & "<br/><br/>" & "Below is the snapshot of your audit." & "<br/><br/>" & "Please reach out for any clarification." & "<br/><br/>" & "<u><b>Session Details:<b/><u/>" & "<br/><br/>" & "<table border=1><tbody><tr><th>Course Run Code:</th><td>" & Range("F11").Value & "</td></tr>" & "<tr><th>Session Title:</th><td>" & Range("F12").Value & "</td></tr>" & "<tr><th>Session Date:</th><td>" & Range("F13").Value & "</td></tr>" & "<tr><th>Session Time (IST):</th><td>" & Range("F14").Value & "</td></tr></tbody></table>" & "<br/>" & "<u><b>Observation/Actions:<b/><u/>"
.Display
Set emailItem = Nothing
Set emailApplication = Nothing
End With
End Sub
VBA Code:
Sub ScreenShot()
'
' ScreenShot Macro
'
'
Cells.Select
Range("D9").Activate
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
Sheets("Image Captured Here").Select
Range("A1").Select
ActiveSheet.Paste
Sheets("Quality Form").Select
Range("D9").Select
Selection.Copy
Application.CutCopyMode = False
End Sub