• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

email from lotus notes

dev9kumar

New Member
Hi, i am trying to send a email from lotus notes(version9) below mentionedcode works fine for sometime and than i received debugging error. As i new to VBA I dont know what to replace with the code for Set NUIdoc = NUIWorkSpace.EDITDocument(True, NDoc) and .GotoField ("Body").

Any help really appreciated.

thanks
Dev


Code:
Sub Notes_Email_Excel_Cells()

    Dim NSession As Object
    Dim NDatabase As Object
    Dim NUIWorkSpace As Object
    Dim NDoc As Object
    Dim NUIdoc As Object
 
    Set NSession = CreateObject("Notes.NotesSession")
    Set NUIWorkSpace = CreateObject("Notes.NotesUIWorkspace")
    Set NDatabase = NSession.GetDatabase("", "")
 
    If Not NDatabase.IsOpen Then
        NDatabase.OPENMAIL
    End If
         
    Set NDoc = NDatabase.CreateDocument
 
    With NDoc
        .SendTo = Range("F6").Value
        .CopyTo = ""
        .Subject = Range("Y17").Value & " " & Now
        .body = "."
        .Save True, False
    End With
       
    Set NUIdoc = NUIWorkSpace.EDITDocument(True, NDoc)
    With NUIdoc
   
        .GotoField ("Body")
        .FINDSTRING "."
    ActiveSheet.Shapes.Range(Array("Picture 5")).Select
    Selection.Copy
 
        .Paste
        Application.CutCopyMode = False
     
        '
        End With
 
    Set NSession = Nothing
 
End Sub
 
Last edited by a moderator:
Welcome to Chandoo. org forums!

If you want to know more about Lotus Notes VBA then you can use following reference:

This is IBM's Red Book Reference for using VBA for Lotus Notes Automation.
http://www.redbooks.ibm.com/redbooks/pdfs/sg245670.pdf

In below link you will find what I had tried and references I found out over internet.
http://www.vbaexpress.com/forum/sho...sing-Excel-To-Send-Emails-Through-Lotus-Notes

That said, you will need a user who is currently using Lotus Notes. I had tried few things myself but I don't use Lotus Notes any more so I may not be of any active help.

From your description it seems that code works sometimes and doesn't in some other cases. Have you identified anything that differs?

One thing important here is the way Lotus Notes being initialized here i.e. using OLE Automation. It simply means your Lotus Notes session must be up and running before you run the code which you have posted. Is this where it is not working?
 
Thanks shri for replying...

on the above mentioned code whenever the new message is generate in body full stop is insert and its copy picture from sheet and goes back to body find full stop and paste the picture . what i am looking is vba should directly paste the picture in the body rather inserting full stop or than finding it again to paste picture.
 
It could be due to lotus notes limitation that code is written as such and this could be the work around. As indicated before, I cannot verify as I don't have Lotus Notes.

Can you clarify the exact issue:
Is it not working the way you want it to? What issue is it posing for you?
 
Hard to say what is the issue :)

1. You need to locate following object:
"NotesUIDocument" by referencing the lotus notes objects library by using Tools >> References in Visual Basic Editor.

2. And then using object browser (F2) locate this object. Check its methods and properties. Once you locate method "EDITDocument" then see what it is expecting to pass as arguments and type of arguments.

Using this you should be able to find if the code line is appropriate or not.

Also after bit of search I found that there's developer forum by IBM. You can also register and post I suppose.
http://www-10.lotus.com/ldd/nd6forum.nsf
 
Shri,

I tried but it seems not working out ...

what i want a code for pasting a picture from excel sheet (picture 5) to body of the email, without editing the body for e.g the below code does that but it first goes to body write (.) and again it goes back to body find (.) and paste the picture. i want it to be pasted in the first time itself rather rounding around.

Code:
Set NDoc = NDatabase.CreateDocument

   With NDoc
        .SendTo = Range("F6").Value
        .CopyTo = ""
        .Subject = Range("Y17").Value & " " & Now
        .body = "."
        .Save True, False
   EndWith
      
   Set NUIdoc = NUIWorkSpace.EDITDocument(True, NDoc)
   With NUIdoc
  
        .GotoField ("Body")
        .FINDSTRING "."
    ActiveSheet.Shapes.Range(Array("Picture 5")).Select
    Selection.Copy

        .Paste

MOD EDIT: CODE TAGS ADDED
 
Last edited by a moderator:
If you choose to cross-post, you should post cross-post link here as well as link of this thread to other forum so that people who answer you are aware.

Other than that, I found a link to EditDocument Method.
http://www-12.lotus.com/ldd/doc/lot...901840aa18685af08525642e00757f4f?OpenDocument

As a first try to change from
Code:
Set NUIdoc = NUIWorkSpace.EDITDocument(True, NDoc)
to
Code:
Set NUIdoc = NUIWorkSpace.EDITDocument(True, NDoc,False)

And this line from
Code:
   With NUIdoc
  
        .GotoField ("Body")
        .FINDSTRING "."
    ActiveSheet.Shapes.Range(Array("Picture 5")).Select
    Selection.Copy

        .Paste
        Application.CutCopyMode = False
    
              End With
to
Code:
With NUIdoc
        Call .GotoField ("Body")
        Call .FINDSTRING "."
        ActiveSheet.Shapes.Range(Array("Picture 5")).Copy
        Call .Paste
        Application.CutCopyMode = False
End With

Note that this shot in the dark as I do not have Lotus Notes to verify.
 
Last edited:
Hi Shri,

Happy Diwali...

i changed the code as you've mentioned above, but still the same debug arise on the line Set NUIdoc = NUIWorkSpace.EDITDocument(True, NDoc,False).

i know i am bothering you a lot but i need this to be worked.
 
I wish I could help you but since I don't have Lotus Notes I really cannot go ahead playing blindly.

Sorry, you will have to wait for someone here to turn up or post in other forums (by following rules of cross-posting).
 
Back
Top