Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1072871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:55:07+00:00 2026-05-16T20:55:07+00:00

I have a VBA function that initializes a lotus notes session, creates a document

  • 0

I have a VBA function that initializes a lotus notes session, creates a document and mails it. It also accepts as an optional parameter a NotesRichTextItem which I append to the body of the email.

However, I am getting the error message “All objects must be from the same session”. How do I ‘import’ this NotesRichTextItem into my session?

Edit-Code added

Sub SendLotusMail(SubjTxt As String, _
                BodyTxt As String, _
                EmailTo As String, _
                EmailCC As String, _
                AutoSend As Boolean, _
                Attach As String, _
                ReportTitle As String, _
                Optional AppendToBody As NotesRichTextItem = Null)
On Error GoTo EH
    NtSession.Initialize
    OpenMailDb ReportTitle
    Set NtDoc = Ntdb.CreateDocument

    NtDoc.AppendItemValue "Form", "Memo"
    NtDoc.AppendItemValue "SendTo", EmailTo
    NtDoc.AppendItemValue "CopyTo", EmailCC
    NtDoc.AppendItemValue "Subject", SubjTxt
    Set NtBodyRT = NtDoc.CreateRichTextItem("Body")
    NtDoc.AppendItemValue "Body", NtBodyRT
    If Attach <> "" Then NtBodyRT.EmbedObject EMBED_ATTACHMENT, "", Attach, "Attachment"
    NtBodyRT.AppendText BodyTxt

    'This next line throws the error "All objects must be from the same session"
    NtBodyRT.AppendRTItem AppendToBody

Edit-Solution found
I don’t like it very much, but I got around all these issues by passing the RichTextItem object, it’s parent NotesDocument, and it’s parent’s parent NotesSession to this function. So, now I’m calling this procedure with 3 optional objects instead of 1. Hooray.

Edit-New Solution found
Well, the previous solution was causing me problems, so until I find (or someone suggests) a workaround, I’ll just use some custom email procedures for the reports that require it. It does duplicate some code, but not significantly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:55:08+00:00Added an answer on May 16, 2026 at 8:55 pm

    (I’m writing this to close out my question)
    I’ve gotten around this issue by just having separate email procs for the reports that require custom setups. Yes, there is some duplication of code, but it’s far better than the behemoth I was about to make.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using VBA i have a set of functions that return an ADODB.Recordset where all
I have trouble comparing 2 double in Excel VBA suppose that I have the
I have an Excel file that has a bunch of VBA and macro code
I have written an Excel VBA macro which imports data from a HTML file
I have a test in Excel VBA: If (test1) And (test2) And (test3) Then
I have created a report in MS Access report and write some VBA code
I have a few modules of block of code in VBA to run on
I have written a few modules of code in Access vba. Each code runs
I have to make column charts in Excel using VBA only (no user input).
I have to display a column chart in a user form in VBA. Exporting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.