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 6912445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:05:35+00:00 2026-05-27T09:05:35+00:00

I have working VBA code, but I can’t convert it to C#. I have

  • 0

I have working VBA code, but I can’t convert it to C#.
I have tried, but my C# skills are failing me.

The code below creates new message and opens new email in Lotus Notes (using active session if Lotus application is active) OR opens a new instance of Notes if Notes is not running.

Could you please assist?

Sub SendMail()
Dim Notes As Object
Dim db As Object
Dim WorkSpace As Object
Dim UIdoc As Object
Dim userName As String
Dim MailDbName As String
Set Notes = CreateObject("Notes.NotesSession")
userName = Notes.userName
MailDbName = Left$(userName, 1) & Right$(userName, (Len(userName) - InStr(1, userName, " "))) & ".nsf"
Set db = Notes.GetDataBase(vbNullString, MailDbName)
Set WorkSpace = CreateObject("Notes.NotesUIWorkspace")
Call WorkSpace.ComposeDocument(, , "Memo")
Set UIdoc = WorkSpace.currentdocument
Recipient = "test@email.com"
CCD = "test2@email.com"
Call UIdoc.FieldSetText("EnterSendTo", Recipient)
Call UIdoc.FieldSetText("EnterCopyTo", CCD)
Subject1 = "Subject")
Call UIdoc.FieldSetText("Subject", Subject1)
Call UIdoc.GotoField("Body")
Call UIdoc.INSERTTEXT("This text goes to body")
Application.CutCopyMode = False
Set UIdoc = Nothing
Set WorkSpace = Nothing
Set db = Nothing
Set Notes = Nothing
END SUB

Thank you!

Thank you competent_tech for solution:

    public void SendMail() 
{ 
    dynamic Notes = null; 
    object db = null; 
    dynamic WorkSpace = null; 
    dynamic UIdoc = null; 
    string userName = null; 
    string MailDbName = null; 
    Notes = Activator.CreateInstance(Type.GetTypeFromProgID("Notes.NotesSession")); 
    userName = Notes.userName; 
    MailDbName = userName.Substring(0, 1) + userName.Substring(userName.Length - ((userName.Length - (userName.IndexOf(" ", 0) + 1)))) + ".nsf"; 
    db = Notes.GetDataBase(null, MailDbName); 
    WorkSpace = Activator.CreateInstance(Type.GetTypeFromProgID("Notes.NotesUIWorkspace")); 
    WorkSpace.ComposeDocument("", "", "Memo"); 
    UIdoc = WorkSpace.currentdocument; 
    Recipient = "test@email.com"; 
    CCD = "test2@email.com"; 
    UIdoc.FieldSetText("EnterSendTo", Recipient); 
    UIdoc.FieldSetText("EnterCopyTo", CCD); 
    Subject1 = "Subject"; 
    UIdoc.FieldSetText("Subject", Subject1); 
    UIdoc.GotoField("Body"); 
    UIdoc.INSERTTEXT("This text goes to body"); 
    UIdoc = null; 
    WorkSpace = null; 
    db = null; 
    Notes = null; 
} 
  • 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-27T09:05:36+00:00Added an answer on May 27, 2026 at 9:05 am

    It’s going to be roughly:

        public void SendMail()
        {
            dynamic Notes = null;
            object db = null;
            dynamic WorkSpace = null;
            dynamic UIdoc = null;
            string userName = null;
            string MailDbName = null;
            Notes = Activator.CreateInstance(Type.GetTypeFromProgID("Notes.NotesSession"));
            userName = Notes.userName;
            MailDbName = userName.Substring(0, 1) + userName.Substring(userName.Length - ((userName.Length - (userName.IndexOf(" ", 0) + 1)))) + ".nsf";
            db = Notes.GetDataBase(null, MailDbName);
            WorkSpace = Activator.CreateInstance(Type.GetTypeFromProgID("Notes.NotesUIWorkspace"));
            WorkSpace.ComposeDocument("", "", "Memo");
            UIdoc = WorkSpace.currentdocument;
            Recipient = "test@email.com";
            CCD = "test2@email.com";
            UIdoc.FieldSetText("EnterSendTo", Recipient);
            UIdoc.FieldSetText("EnterCopyTo", CCD);
            Subject1 = "Subject";
            UIdoc.FieldSetText("Subject", Subject1);
            UIdoc.GotoField("Body");
            UIdoc.INSERTTEXT("This text goes to body");
            UIdoc = null;
            WorkSpace = null;
            db = null;
            Notes = null;
        }
    

    It would be better if you had the com object that you could add as a reference, but there could be versioning issues there. Also note that this code assumes late binding.

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

Sidebar

Related Questions

I'm not sure why my code is not working.. I have code in vba
I have been working on some legacy C++ code that uses variable length structures
I have been working with relational databases for sometime, but it only recently occurred
I have working with email option. i can send the Email using the intent
I have the following vba-code in an MS-Access97-frontend which opens a word-document stored on
I am working on a spreadsheet with lots of VBA code in it. Most
I am currently working on a project to convert a number of Excel VBA
I'm new to VBA but I'm trying to get a DYMO LabelWriter to work
I put together some VBA code for Outlook 2007 which has been working predominantly
I’ve just upgraded and have a problem. Previously this code was working fine: page

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.