Change fonts in access vba to send mail in lotus notes

Dian S
Dian S used Ask the Experts™
Hi ,

I know only basic vba.
I would like to send mail in lotus notes via microsoft access vba.
I found this code in the IBM website as example codes to change the fonts.

I copy paste to my script but it stopt on  "Dim session As New NotesSession" and error message is user-defined type is not defined.
Could you please help?
Many thanks

Sub Initialize
  Dim session As New NotesSession
  Dim db As NotesDatabase
  Set db = session.CurrentDatabase
  Dim doc As New NotesDocument(db)
  Call doc.AppendItemValue("From", session.UserName)
  Call doc.AppendItemValue("Subject",  _
  "Meeting time changed")
  Dim richStyle As NotesRichTextStyle
  Set richStyle = session.CreateRichTextStyle
  Dim richText As New NotesRichTextItem(doc, "Body")
  richStyle.NotesFont = FONT_HELV
  Call richText.AppendStyle(richStyle)
  Call richText.AppendText("The meeting is at ")
  richStyle.NotesFont = FONT_COURIER
  Call richText.AppendStyle(richStyle)
  Call richText.AppendText("3:00")
  richStyle.NotesFont = FONT_HELV
  Call richText.AppendStyle(richStyle)
  Call richText.AppendText(" not 2:00")
  Call doc.Save(True, False)
End Sub
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Sjef BosmanGroupware Consultant

If this question is in any way related to your other question, then I'd suggest to use CSS styles. A lot easier to do.
John TsioumprisSoftware & Systems Engineer

Based on the post here i think you need to change the code like this...i am afraid i don't have Lotus Notes to check
Dim session as Object
Dim db As Object
Dim doc As Object
Set session = CreateObject("Notes.NotesSession")
Set db =session.CurrentDatabase

Open in new window


Hi John,  Many thanks for your suggestion, but it still does not work.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

John TsioumprisSoftware & Systems Engineer

Too i said i don't have Lotus Notes...where do you get the problem ?
Sjef BosmanGroupware Consultant

The language of the code you have is LotusScript. It closely resembles Visual Basic, but it is not the same.

What exactly would you like to change? You should know that there are only 3 pre-defined fonts in Notes, so if you want to use yet a 4th one you're out of luck. That is, unless you want to use MIME, as I suggested in your other question...

Just an example of how to write VBA code that works on Notes (it doesn't solve your fonts problem):
Dim objMailStyle As Object
Dim objMailSession As Object

Set objMailStyle = objMailSession.CREATERICHTEXTSTYLE
        objMailStyle.NOTESFONT = 1
        objMailStyle.Bold = True
        objMailStyle.FontSize = 10
        objMailStyle.NotesColor = 14
        objMailRT.APPENDSTYLE objMailStyle

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial