PDA

View Full Version : Send Notes Mail out of Excel with monospaced body



JC61
04-10-2018, 09:14 AM
This macro should send a Notes-Mail out of Excel 2016 VBA.
The "body" should be monospaced (courier font for instance).
It works for defining style (bold/unbold) and font size, but not for the font type itself.


Maybe someone can help and find my mistake. Thank You.


This is the code :



Sub Send_Mail()

Dim Maildb As Object
Dim MailDoc As Object
Dim session As Object
Dim rti As Object
Dim rts As Object

Set session = CreateObject("Notes.NotesSession")
Set Maildb = session.CurrentDatabase
Set MailDoc = Maildb.createDocument
Set rts = session.CreateRichTextStyle
Set rti = MailDoc.CreateRichTextItem("Body")

BodyText = ""
BodyText = BodyText & "****************************************************" & vbCrLf
BodyText = BodyText & "* *** ** * * * ***** ***** * * ***** *" & vbCrLf
BodyText = BodyText & "* * * * * * * * * * * * * *" & vbCrLf
BodyText = BodyText & "* ***** * ** *** * *** * * *" & vbCrLf
BodyText = BodyText & "* * * * * * * * * * * *" & vbCrLf
BodyText = BodyText & "* * * * * * * ***** * * * *" & vbCrLf
BodyText = BodyText & "****************************************************" & vbCrLf


rts.NotesFont = FONT_COURIER
rts.Bold = True
rts.FontSize = 16
Call rti.appendstyle(rts)
Call rti.appendtext(BodyText)


Recipient = mail.adress

With MailDoc
.form = "Memo"
.sendto = Recipient
.Subject = "Re : ***xx"
.ReturnReceipt = "1"
End With

MailDoc.SaveMessageOnSend = True
MailDoc.SEND 0, Recipient

Set Maildb = Nothing
Set MailDoc = Nothing
Set session = Nothing
Set rti = Nothing
Set rts = Nothing

MsgBox "Email sent !", vbOKOnly

End Sub