Hello All.
I have a workbook that sends a copy via Lotus Notes. The body of the e-mail is text from the excel workbook. Unfortunately it does not look good and I would like to change the code to paste either as HTML, Jpeg or some option to make it readable for recipients without the need to open the excel attachment.
Here is my code:
Appreciate any and all help.
vDay = 0
End Select
EMBED_ATTACHMENT = 1454
' Define the range to copy (adjust the range as needed)
Set rng = ActiveSheet.Range("A1:U20")
' Convert the range to text by looping through each cell
rngText = ""
For Each cell In rng
rngText = rngText & cell.Value & vbTab
If cell.Column = rng.Columns.Count Then
rngText = rngText & vbNewLine
End If
Next cell
' Prepare email body with the range text
bodytext = "Good Morning," & vbNewLine & vbNewLine
bodytext = bodytext & "Attached above is the revenue report from last night." & vbNewLine & vbNewLine
bodytext = bodytext & "Below is a summary of the report:" & vbNewLine & vbNewLine
bodytext = bodytext & rngText & vbNewLine & vbNewLine
bodytext = bodytext & "Thanks," & vbNewLine
bodytext = bodytext & "The C Team" & vbNewLine & vbNewLine
bodytext = bodytext & "This is a system generated email."
Set wb1 = ThisWorkbook
stSubject = "Daily C Report - Day " & vDay
' Copy the active sheet to a new temporary workbook.
With ActiveSheet
.Copy
stFileName = "Daily C.xlsm"
End With
noDocument.CREATERICHTEXTITEM("stAttachment")
Set noEmbedObject = noAttachment.EmbedObject(EMBED_ATTACHMENT, "", stAttachment)
' Add values to the created e-mail main properties.
With noDocument
.Form = "Memo"
.SendTo = vaRecipients
.CopyTo = vaCopyTo
.Subject = stSubject
.Body = bodytext
.SaveMessageOnSend = False
.PostedDate = Now()
.Send 0, vaRecipients
End With
ActiveWorkbook.Protect Structure:=True, Windows:=False, Password:=PW
' Delete the temporary workbook.
Kill stAttachment
' Release objects from memory.
Set noEmbedObject = Nothing
Set noAttachment = Nothing
Set noDocument = Nothing
Set noDatabase = Nothing
Set noSession = Nothing
MsgBox "The Daily Revenue Report has been successfully detached and e-mailed to the R",
vbInformation
Application.DisplayAlerts = True
End Sub
Bookmarks