?
Solved

VB code for Accessing  Lotus Notes Mail Box database to transfer the content

Posted on 2006-04-27
14
Medium Priority
?
451 Views
Last Modified: 2013-12-18
Hi Experts,
 I'm developing a program in VB  that should access a Lotus Notes  Mail Box database for extracting the Notes email objects (contents,Attachments)
is there a code  that can help me out  for this purpose?
Thank you
0
Comment
Question by:edwbear1976a
  • 6
  • 4
  • 3
  • +1
14 Comments
 

Author Comment

by:edwbear1976a
ID: 16556092
actually, I'm starting with this code but I don't know what to do next
-----------------------------------------------------------------------------

    password = gPasswordNotes
     
       
   
    '///////////
    Dim MailDbName As String 'THe current users notes mail database name
    Dim rSession As NotesSession 'The notes session
    Dim rDataBase As NotesDatabase ''The mail database
    Dim rDoc As NotesDocument
    Dim UserName As String 'The current users notes name
    '///////////////////////////////////////
   
        Dim MailDoc As Object 'The mail document itself
        Dim AttachME As Object 'The attachment richtextfile object
        Dim EmbedObj As Object 'The embedded object (Attachment)
        Dim password As String

   
    '///////////////////////////////////////
   
   
    Set rSession = New NotesSession
   
    'Next line only works with 5.x and above. Replace password with your password
     
    If Len(Trim(password)) > 0 Then
        rSession.Initialize (password)
    End If

    Set rDataBase = rSession.GetDatabase("", MailDbName)
    'Get the sessions username and then calculate the mail file name
    'You may or may not need this as for MailDBname with some systems you
    'can pass an empty string or using above password you can use other mailboxes.

    UserName = rSession.UserName
   
    MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
   
   
   
    With rDataBase
    'Open the mail database in notes
    If Not .IsOpen Then
        .Open
    End If
    Set rDoc = .GetDocumentByID(NotesId) ' What is the NotesID?
    'or
    Set rDoc = .GetDocumentByUNID(strUnid) 'What is the Unid?
    'or
    Set rDoc = .GetDocumentByURL(strUrl) '
    '//Find out!!!!
    End With
    '//////////--tll  04-27-06
   
0
 

Author Comment

by:edwbear1976a
ID: 16556122
'///////////
        Dim MailDbName As String 'THe current users notes mail database name
        Dim rSession As NotesSession 'The notes session
        Dim rDataBase As NotesDatabase ''The mail database
        Dim rDoc As NotesDocument
        Dim UserName As String 'The current users notes name
    '///////////////////////////////////////
   
        Dim MailDoc As Object 'The mail document itself
        Dim AttachME As Object 'The attachment richtextfile object
        Dim EmbedObj As Object 'The embedded object (Attachment)
        Dim password As String

   
    '///////////////////////////////////////
   
   
    Set rSession = New NotesSession
   
    'Next line only works with 5.x and above. Replace password with your password
     
    If Len(Trim(password)) > 0 Then
        rSession.Initialize (password)
    End If

     MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
    Set rDataBase = rSession.GetDatabase("", MailDbName)
    'Get the sessions username and then calculate the mail file name
    'You may or may not need this as for MailDBname with some systems you
    'can pass an empty string or using above password you can use other mailboxes.

    UserName = rSession.UserName
   
   
   
   
   
    With rDataBase
    'Open the mail database in notes
    If Not .IsOpen Then
        .Open
    End If
    Set rDoc = .GetDocumentByID(NotesId) ' What is the NotesID?
    'or
    Set rDoc = .GetDocumentByUNID(strUnid) 'What is the Unid?
    'or
    Set rDoc = .GetDocumentByURL(strUrl) '
    '//Find out!!!!
    End With
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 16557427
What are you trying to do ?

How many mail boxes will this be used for  ?
What version of Notes Server ?Do you have a Notes Client ?
You may be able to extract text, but attachments and other stuff may be a problem.

Please provide more details of your final goal.

I hope this helps !
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 18

Expert Comment

by:marilyng
ID: 16558492
Hi edwbear1976a,
> password = gPasswordNotes

Agree with sysExpert.. what is it that you are trying to do that you want to bypass Notes Security.. ?

I don't believe any expert will assist you with this without more details of intent.
Regards!
0
 
LVL 14

Accepted Solution

by:
cezarF earned 1800 total points
ID: 16558564
edwbear1976a ,

you would need the following lotus notes COM object. refer to lotus notes designer help on how to use them.

-NotesSession object
 Dim session As NotesSession
 Set session = CreateObject("Lotus.NotesSession")
 Call session.Initialize("passwordOptional") ' initialize the session

-NotesDatabase Object
 Dim db As NotesDatabase
 set db = session.GetDatabase(<server>, <dbname>)

-NotesView Object
 Dim view As NotesView
 set view = db.GetView(<viewname or folder name>)

-NotesDocument Object
 Dim doc As NotesDocument
 set doc = view.GetfirstDocument

-NotesRichTextItem Object
 Dim rtitem As NotesRichTextItem ' for the body of the email

-loop thru all docs in the view/folder
 while not doc is nothing
    Set rtitem = doc.GetFirstItem( "Body" )
    ....
    ....
    set doc = view.GetNextDocument(doc)
 wend


hope this helps.








0
 
LVL 18

Expert Comment

by:marilyng
ID: 16558654
Cezar, pardon me for saying this, but why did you submit a suggestion without knowing what he/she intends to do with it?
0
 
LVL 14

Expert Comment

by:cezarF
ID: 16558758
marilyng, what do you think his/her intentions are? if (s)he wants to access somebody else's email don't you think that (s)he needs the password to do it?

looking thru his/her code, it is clear that the mail database that the program would access is the mail db of the currently logged-in user.

   >> UserName = rSession.UserName  
   >> MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"

besides, everything in my suggestion can be found the domino designer help database.  
0
 
LVL 14

Expert Comment

by:cezarF
ID: 16558843
marilyng, if your concern is me posting my suggestion after your >>I don't believe any expert will assist you with this without more details of intent.<< comment, this is not intentional. you might have posted your comment while i'm working with my suggestion.
0
 

Author Comment

by:edwbear1976a
ID: 16558916
Hi EveryBody thanks for your notes
Maryling
First thing, My goal is to access " text" not objects
The little proyect is to get the text that every moment will be sent to a common mail box, expecially created to that purpose (so you figuere out that the I will know the   pwd and everything about that account) so that account is a recipient that will get only mails that will  have a special structure (I mean about the information) so I only have to access the text.

just let me know if you need more information about it

0
 

Author Comment

by:edwbear1976a
ID: 16558969
and Besides as CesarF says, my code uses and needs  a password  so that means that  I should know it  if I want to make it run, in case I Want to get the information about anybody else I will always need a password... so don't worry about it,the account is created for 2 purposes : be a recipient and to get by a program the information wich is structured  (we used to make that with Outlook but our company moved to Lotus Notes)
0
 

Author Comment

by:edwbear1976a
ID: 16559001
Hi CesarF and thanks for you note,

this part of your code  is very new for me
/////////////////////////////////////////////////////////////
-NotesView Object
 Dim view As NotesView
 set view = db.GetView(<viewname or folder name>)
////////////////////////////////////////////////////////////
How can I get to know the <viewname of folder name>, I never heard about those things before

thanks
Edw
0
 
LVL 14

Expert Comment

by:cezarF
ID: 16559097
marilyn, guess edw's intention is pure. :)

edw,
if you are using a standard mail template, you can use the "($Inbox)" folder. just note that you need to check if doc.form = "Memo" before getting the body of the mail as the inbox folder also displays other docs aside from the Memo form.
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16563504
No, I don't believe we can assume that, especially when the facility is available to use Notes to collect massage any information within a database within Notes Security.   Doing it this way is bypassing Notes security, irregardless if the user is trying to troll his own mail or someone else's mail.  This appears to be a back door request to use an external program to bypass Notes Internal Security.  

If this is a sanctioned request from the company, then the Company needs to hire a professional to construct the solution.
0
 

Author Comment

by:edwbear1976a
ID: 16569601
Hi and thanks cezarF the code works fine, I'm working with the
Notes.NotesSession instead the "Lotus.NotesSession" and it goes well.
The question was about getting body text and it's solved.
Your answered quick and you had a lot of sense and helpful feelings
I will post another question about getting the mail subject(that will help me to choose the right item to get the text.. but that's another question


About things that Marilying said, I respect them, but it's my right to not agree with them. I've got General Manager Privileges over that account that it's only a recipient  not a  big deal at all..but anyhow he's an expert, he's got his reasons  and I won't try to change its mind. I wish the best for him

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Integration Management Part 2
Loops Section Overview

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question