Link to home
Start Free TrialLog in
Avatar of dsacker
dsackerFlag for United States of America

asked on

ActiveX Component Can't Create Object

Because of a corporate buyout, our desktops have recently been "re-imaged".  Now I cannot send email via my VB/VBA code.  The following technique used to work well:

    Set Session = CreateObject("Notes.NotesSession")
    UserName = Session.UserName
    MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
    Set MailDb = Session.GETDATABASE("", MailDbName)

    If MailDb.ISOPEN = False Then
       MailDb.OPENMAIL
    End If

    ...

However, the "Set Session" line now returns an "ActiveX Component Can't Create Object" error.  I've attempted the following solutions to no avail:

    *  I registered (regsvr32) C:\lotus\notes\nlsxbe.dll ... still cannot CreateObject("Notes.NotesSession")
    *  I changed the code to CreateObject("Lotus.NotesSession"), instead of "Notes.NotesSession" ... this created a world of headaches (i.e., password prompting, MailDoc.Form/Subject/etc properties not available)

If there is/are some other DLL(s) to register, some switches in Lotus Notes to set, I'm definitely open for suggestions.  My goal is simply to automatically email an Excel spreadsheet out to a list of recipients, streamlessly ... as before.

Thanks.
Avatar of qwaletee
qwaletee

I would re-install Notes using a standard install, instead of the image.  Winstall has ben known to do a real number on Notes installations.
Avatar of dsacker

ASKER

Can't ... I have two desktop machines, both "re-imaged".  Notes was installed on both of them after the re-imaging, via "approved" protocols.  In other words, I'm stuck having to get this to work in my existing environment.

If I go the "Lotus.NotesSession" approach, there are numerous headaches, but it looks like after a lengthy time I might be able to peril them all.  I'm simply hoping for some "rabbit in the hat" (lol).

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of qwaletee
qwaletee

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Let's not forget, if it doesn't work, the image is wrong.  Your desktop engineering guys gotta support that!

I would be interested in knowing how you finally resolve the problem.
Oh, and by the way, the following is a really bad practice:
   MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
Probably makes no difference as you are doing this in a fairly closed environment, but there is no guarantee that a mail file name matches finitial + lname.  The proper way is as follows:

Set MailDB = session.getDatabase( "", "" )
MailDB.OpenMail

Which is actually two lines instead of three :)
Avatar of dsacker

ASKER

My key info is as follows:

[HKEY_LOCAL_MACHINE\SOFTWARE\CLASSES\CLSID\]

   {29131539-2EED-1069-BF5D-00DD011186B7} = "Lotus Domino Session"

      ...\InprocServer32
            Default = C:\Lotus\Notes\nlsxbe.dll
            ThreadingModel = Both

      ...\ProgID
            Default = Lotus.NotesSession.1

      ...\TypeLib
            Default = {29131520-2EED-1069-BF5D-00DD011186B7}

      ...\VersionIndependentProgID
            Default = Lotus.NotesSession

I have no keys that contain the values "Notes.NotesSession" or "notes.exe /Automation".  Hmmmm.

I've come to understand the enclosed-ness of coding MailDbName = Left$ .... it was taken from here on experts-exchange and (luckily) worked at the time.  I wouldn't yet know if Session.GetDatabase("","") will work until I can get this damn Notes.NotesSession resolved (lol).

Your help is very much appreciated.
You definitely need the [HKEY_LOCAL_MACHINE\SOFTWARE\CLASSES\CLSID\{29131401-2EED-1069-BF5D-00DD011186B7}] key.
I forgot to give you the reg file for [HKEY_CLASSES_ROOT\Notes.NotesSession] -- that one will obviously be just as key as the 401:

REGEDIT4

[HKEY_CLASSES_ROOT\Notes.NotesSession]
@="Notes R4.0 NotesSession"

[HKEY_CLASSES_ROOT\Notes.NotesSession\Clsid]
@="{29131401-2EED-1069-BF5D-00DD011186B7}"


Avatar of dsacker

ASKER

Thanks for all your help ... I know it wasn't beaucoup points, but it is very much appreciated.

I've finally gotten the code to work ... here's what I'm now using in place of the former Notes.NotesSession approach:

Private Sub SendNotesEmail(Subject As String, _
                          ByVal Attachment As String, _
                          Recipient As String, _
                          BodyText As String, _
                          SaveIt As Boolean)
    Dim AttachME        As Object   'The attachment richtextfile object
    Dim EmbedObj        As Object   'The embedded object (Attachment)
    Dim MailDb          As Object   'The mail database
    Dim MailDbName      As String   'The current users notes mail database name
    Dim MailDoc         As Object   'The mail document itself
    Dim MailFile        As String   'The mail ename
    Dim Session         As Object   'The notes session
    Dim MailList()      As String   'Multiple recipients

    Set Session = CreateObject("Lotus.NotesSession")
    Session.Initialize
    Set MailDb = Session.GetDbDirectory("").OpenMailDatabase

    If MailDb.IsOpen = False Then
       MailDb.Open
    End If

    Set MailDoc = MailDb.CreateDocument

    MailDoc.AppendItemValue "Form", "Memo"
    MailDoc.AppendItemValue "Subject", Subject
    MailDoc.AppendItemValue "Body", File_Contents(BodyText)
    MailDoc.AppendItemValue "PostedDate", Now()
    MailDoc.AppendItemValue "SendTo", MailList
    MailDoc.SaveMessageOnSend = SaveIt
   
    Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
    Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")

    MailDoc.Send True

    Set EmbedObj = Nothing
    Set AttachME = Nothing
    Set MailDoc = Nothing
    Set MailDb = Nothing
    Set Session = Nothing
End Sub

I had to go into my Lotus Notes settings, i.e., Files, Tools, User ID ... and then turn on the checkbox "Don't prompt for a password from other Notes-based programs", in order to get it to run streamlessly.  Hope this benefits others.

Again, thanks.
Notes.NotesSession ("COM") is still the better way to go.  You never got that working again :( ?
Gwaletee.

I use to have my Lotus working using the CreateObject("Notes.NotesSession") with no problems.

Now I've moved and the image has changed, etc...
I get the ActiveX 429 error at this line.
Regsvr32 didn't help though it did register successfully.

I went into the registry and didn't find ANY 401 entries.
So I figure I would go ahead and create them.
No luck.

My problem still exist at the same point.

I do have a question about the  localserver and localserver32 settings you gave.  
Can I find those settings on my own since they are not already in the registry without having to go through admin?

The notes.exe I see is local and putting that in those places doesn't help either.

I can work around it using dsaker's method, but I really would like to get this one back up and running.   For now I'm using his method, but your help would be welcome.

I mean this will do because I can continue to automate some mail.
I have to read back and see where people answered my call about automating reading mail in the same process to help dictate outgoing mail.


XP PRO / Lotus R5

Thanks!
No piggybacking.  Ask your own question.
I have tried something else, whenever i create lotusnotes mail DB path in the same PC where the program is, it works fine, but when i give it the server path or other PC path it gave me the same error!

Can you guide me how can connect it to the server may b i did something wrong in my code!