riskassure
Programmer
Hello, I have been using VBA to send Lotus Notes email for a while. The general code is the following:
Public Sub SendNotesMail(Subject As String, ByVal Recipient As String, BodyText As String, SaveIt As Boolean)
'Set up the objects required for Automation into lotus notes
Dim Maildb As Object 'The mail database
Dim MailDoc As Object 'The mail document itself
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
'Open the mail database in notes
Set Maildb = Session.GetDatabase("", "mail\username.nsf")
If Maildb.IsOpen = False Then
Maildb.OPENMAIL
End If
'Set up the new mail document
Set MailDoc = Maildb.CreateDocument
MailDoc.Form = "Memo"
MailDoc.sendto = Recipient
MailDoc.Subject = Subject
Set DocBody = MailDoc.CreateRichTextItem("Body")
DocBody.AppendText (BodyText)
MailDoc.Sign
MailDoc.IsSigned = True
MailDoc.SignOnSend = True
MailDoc.SaveMessageOnSend = SaveIt
'Send the document
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
MailDoc.Send 0
MailDoc.Save True, True, False
Exit Sub
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set Session = Nothing
End Sub
Notice that the BodyText above is just a string. Now, I want to replace the text to an HTML document (so basically embed a HTML document in the body of the mail). How would I do this? I know you can import an HTML document in Lotus Notes, so is there way to do this in VBA?
Thanks
~~CW~~
Public Sub SendNotesMail(Subject As String, ByVal Recipient As String, BodyText As String, SaveIt As Boolean)
'Set up the objects required for Automation into lotus notes
Dim Maildb As Object 'The mail database
Dim MailDoc As Object 'The mail document itself
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
'Open the mail database in notes
Set Maildb = Session.GetDatabase("", "mail\username.nsf")
If Maildb.IsOpen = False Then
Maildb.OPENMAIL
End If
'Set up the new mail document
Set MailDoc = Maildb.CreateDocument
MailDoc.Form = "Memo"
MailDoc.sendto = Recipient
MailDoc.Subject = Subject
Set DocBody = MailDoc.CreateRichTextItem("Body")
DocBody.AppendText (BodyText)
MailDoc.Sign
MailDoc.IsSigned = True
MailDoc.SignOnSend = True
MailDoc.SaveMessageOnSend = SaveIt
'Send the document
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
MailDoc.Send 0
MailDoc.Save True, True, False
Exit Sub
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set Session = Nothing
End Sub
Notice that the BodyText above is just a string. Now, I want to replace the text to an HTML document (so basically embed a HTML document in the body of the mail). How would I do this? I know you can import an HTML document in Lotus Notes, so is there way to do this in VBA?
Thanks
~~CW~~