I have been trying to get a MS Excel spread sheet to email specific content of an Excel sheet to an email message. I have found the code that allows for me to generate an email message and that work swimmingly. Especially if I wanted to attach the Spread sheet (works great as well). What I would really like to do (that I have determined cannot be done because the NotesUI does not support COM) is esentially:
VBA for Excel -> Select Cells -> Paste into a Notes Document (maintaining the Cell Formatting).
The code that I have (see end of question) that works will only copy the text to the email document (I have removed all comments for the code, I originally got this code from the internet and modified it slightly to give credit to the owner whoever they may be).
I have given up on the Copy and Paste approach (which would have worked great) and have decided to try and use HTML formatting to get as close to the results that I would like. I am thinking some thing like:
Dim BodyText As String -- > Then --> BodyText = "MY HTML Code" --> then dump that to the Body of the email message. Which does not work, the text is exactly as I send it, but the client does not execute the HTML - it displays it. I have been trying to figure out Lotus Notes PassThru HTML but cannot get it to work either.
Any suggestions or pointers will be greatly appreciated.
##### Begin Excel VBA Code to pass email to Notes #####
Private Sub CommandButton1_Click()
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'The current users notes mail database name
Dim MailDoc As Object 'The mail document itself
Dim AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
Dim Subject As String 'The subject string
Dim Attachment As String 'The path to the attachemnt string
Dim Recipient As String 'The Recipient string (or you could use the list)
Dim Recip(10) As Variant 'The Recipient list
Dim BodyText As String 'The body text
Dim SaveIt As Boolean 'Save to sent mail
Dim WasOpen As Integer 'Checking to see if the Mail DB was already
'open to determine if session should be
'closed (0) or left alone (1)
Dim ClipBoard As DataObject 'Data object for getting text from clipboard
Subject = "This is a Test Email Messag"
Recipient = "Notes Email User"pying it to Clipboard
Sheets("Sheet1").Select
Range("A5:G19").Select
Selection.Copy
Set ClipBoard = New DataObject
ClipBoard.GetFromClipboard
SaveIt = True
Set Session = CreateObject("Notes.NotesS
ession")
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.ISOPEN = True Then
WasOpen = 1 'Already open for mail
Else
WasOpen = 0
Maildb.OPENMAIL 'This will prompt you for password
End If
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = Recipient 'Or use Racip(10) for multiple
MailDoc.Subject = Subject
MailDoc.body = ClipBoard.GetText(1)
MailDoc.SAVEMESSAGEONSEND = SaveIt
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM
("Attachme
nt")
Set EmbedObj = AttachME.EMBEDOBJECT(1454,
"", Attachment, "Attachment")
MailDoc.CREATERICHTEXTITEM
("Attachment")
End If
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
MailDoc.SEND 0, Recipient
'Clean Up'
Range("A1").Select
Application.CutCopyMode = False
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set EmbedObj = Nothing
If WasOpen = 1 Then
Set Session = Nothing
ElseIf WasOpen = 0 Then
Session.Close
Set Session = Nothing
End If
MsgBox "The Line Down Email was sent", vbOKOnly
End Sub
Thanks again in advance