Solved

Caturing Names

Posted on 2006-11-14
20
216 Views
Last Modified: 2013-12-18
Have the code below I have used to capture the names on a form and send out a customized thank you letter. I have been asked to try and do something similar. I need to take this idea of pulling all the names of the attendees, but instead of sending out the preformatted email, I need to just take the names and drop them into a new standard memo, allowing the trainer to enter their text and send it off. How can I get some code to just capture all the names on the form and drop them into the To: line of a new memo.

Sub Initialize
      Dim db As NotesDatabase
      Set s = New NotesSession
      Set db = s.CurrentDatabase
      
      Dim dc As NotesDocumentCollection
      Set dc = db.UnprocessedDocuments
      Dim varNames(49) As String
      Dim docA As NotesDocument
      Dim docB As NotesDocument
      Dim installDate As NotesDateTime
      Dim installTimeItem As NotesItem            
      Dim item As NotesItem
      Dim i As Integer
      
      On Error Resume Next
      
      Set docA = dc.GetFirstDocument
      For i = 1 To dc.Count
            Set docA = dc.GetNthDocument( i )
            If docA.form(0) = "conf_call_survey"  And docA.survey_sent(0) <> "done" Then      '  this is the document you're pulling names FROM
                  Set docB = db.CreateDocument
                  docB.form = "feedback_request"    '  the document you want to email
                  docB.Subject = "Please take a moment to provide feedback on the " + docA.topic(0) + " conference call you recently attended. "
                  varNames(0) = docA.name(0)
                  varNames(1) = docA.name_1(0)
                  varNames(2) = docA.name_2(0)
                         ............
                  varNames(49) = docA.name_49(0)
                  Set installTimeItem = docA.GetFirstItem("date")
                  Set installDate = installTimeItem.DateTimeValue
                  Call installDate.SetAnyTime
                  Call docB.ReplaceItemValue("date",installDate)      
                  docB.SendTo = varNames                  
                  docB.Principal = "Service Delivery Group"
                  docB.CopyTo = docA.trainer    
                  docB.topic = docA.topic
                  docB.topic1 = docA.topic
                  docB.trainer = docA.trainer(0)
                  docA.survey_sent = "done"
                  Call docA.Save(True,True)
                  
                  Call docB.Send (True)
            Else
                  message = "You have already sent a survey request for this class. This request will not be sent."
                  Messagebox message, MB_OK, "Alert!!"
            End If
      Next
End Sub
0
Comment
Question by:jforget1
  • 7
  • 6
  • 5
  • +1
20 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
Instead of the calls to Save and Send, you need
   
    Dim ws As New NotesUIWorkspace
    docB.Form= "Memo"
    Call ws.EditDocument(True, docB)

and probably you don't need the For-Next-loop.

It is possible that SendTo does not appear. If that's the case, you need to use some other field that are used on the form. Insert
    docB.EnterSendTo= docB.SendTo
before the call to EditDocument.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
By the way, you have 50 lines with
             varNames(0) = docA.name(0)
             varNames(1) = docA.name_1(0)
             varNames(2) = docA.name_2(0)
etc.??      
0
 
LVL 63

Expert Comment

by:SysExpert
Comment Utility
Here is a start.

I still need to just add the memo to open in the GUI.

Sub Initialize
     Dim db As NotesDatabase
     Set s = New NotesSession
     Set db = s.CurrentDatabase
     
     Dim dc As NotesDocumentCollection
     Set dc = db.UnprocessedDocuments
     Dim varNames(49) As String
     Dim docA As NotesDocument
     Dim docB As NotesDocument
     Dim installDate As NotesDateTime
     Dim installTimeItem As NotesItem          
     Dim item As NotesItem
     Dim i As Integer
     
     On Error Resume Next
     
     Set docA = dc.GetFirstDocument
     For i = 1 To dc.Count
          Set docA = dc.GetNthDocument( i )
          If docA.form(0) = "conf_call_survey"  And docA.survey_sent(0) <> "done" Then      '  this is the document you're pulling names FROM
               Set docB = db.CreateDocument
               docB.form = "memo"    '  the document you want to email
               docB.Subject = "Please take a moment to provide feedback on the " + docA.topic(0) + " conference call you recently attended. "
               varNames(0) = docA.name(0)
               varNames(1) = docA.name_1(0)
               varNames(2) = docA.name_2(0)
                         ............
               varNames(49) = docA.name_49(0)
           
               docB.SendTo = varNames              
               docB.Principal = "Service Delivery Group"
             
               docA.survey_sent = "done"
     '          Call docA.Save(True,True)
               
               Call docB.Send (True)
          Else
               message = "You have already sent a survey request for this class. This request will not be sent."
               Messagebox message, MB_OK, "Alert!!"
          End If
     Next
End Sub
0
 
LVL 63

Expert Comment

by:SysExpert
Comment Utility
sjef is fast this morning.

0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
Morning?? It's 17:28 over here... :-P
0
 

Author Comment

by:jforget1
Comment Utility
I will work at getting these into my design this afternoon, I appreciate the quick response.
0
 

Author Comment

by:jforget1
Comment Utility
SysExpert,

I took the code you recommended, I think it is close, but I need it to stop at the new memo the user is creating and after they add their content, they would send from there. HEre is what I have now.

Sub Initialize
      Dim db As NotesDatabase
      Set s = New NotesSession
      Set db = s.CurrentDatabase
      
      Dim dc As NotesDocumentCollection
      Set dc = db.UnprocessedDocuments
      Dim varNames(49) As String
      Dim docA As NotesDocument
      Dim docB As NotesDocument
      Dim installDate As NotesDateTime
      Dim installTimeItem As NotesItem          
      Dim item As NotesItem
      Dim i As Integer
      
      On Error Resume Next
      
      Set docA = dc.GetFirstDocument
      For i = 1 To dc.Count
            Set docA = dc.GetNthDocument( i )
            If docA.form(0) = "conf_call_survey"  Then      '  this is the document you're pulling names FROM
                  Set docB = db.CreateDocument
                  docB.form = "memo"    '  the document you want to email
                  
                  varNames(0) = docA.name(0)
                  varNames(1) = docA.name_1(0)
.......................
                  varNames(49) = docA.name_49(0)
                  
                  docB.SendTo = varNames              
                  
     '          Call docA.Save(True,True)
                  
                  Call docB.Send (True)
            Else
                  message = "You have already sent a survey request for this class. This request will not be sent."
                  Messagebox message, MB_OK, "Alert!!"
            End If
      Next
End Sub
0
 
LVL 63

Accepted Solution

by:
SysExpert earned 500 total points
Comment Utility
SLight changes needed to open in GUI.

Please test !

Sub Initialize
     Dim db As NotesDatabase
     Set s = New NotesSession
     Set db = s.CurrentDatabase
     
     Dim dc As NotesDocumentCollection
     Set dc = db.UnprocessedDocuments
     Dim varNames(49) As String
     Dim docA As NotesDocument
     Dim docB As NotesDocument
     Dim installDate As NotesDateTime
     Dim installTimeItem As NotesItem          
     Dim item As NotesItem
     Dim i As Integer
  Dim ws As New NotesUIWorkspace
   
     
     On Error Resume Next
     
     Set docA = dc.GetFirstDocument
     For i = 1 To dc.Count
          Set docA = dc.GetNthDocument( i )
          If docA.form(0) = "conf_call_survey"  Then      '  this is the document you're pulling names FROM
               Set docB = db.CreateDocument
               docB.form = "memo"    '  the document you want to email
               
               varNames(0) = docA.name(0)
               varNames(1) = docA.name_1(0)
.......................
               varNames(49) = docA.name_49(0)
               
               docB.SendTo = varNames              
                 Call ws.EditDocument(True, docB)  ' add it here
     '          Call docA.Save(True,True)
               
               Call docB.Send (True) ' may not be needed if send directly from GUI
          Else  ' also may be eliminated or surpressed
               message = "You have already sent a survey request for this class. This request will not be sent."
               Messagebox message, MB_OK, "Alert!!"
          End If
     Next
End Sub
0
 

Author Comment

by:jforget1
Comment Utility
I updated the code, it is giving me an error "Cannot find form Memo", yet I am getting a note in my inbox, but it is still not stopping to allow me to add content to the memo. It is just going with the click of the button.
0
 

Author Comment

by:jforget1
Comment Utility
Have tried to take some stuff I have done in the past, but I keep getting the cannot fin form: Memo error and it does not bring up anything after that.

Sub Initialize
      Dim ws As New NotesUIWorkspace
      Dim db As NotesDatabase
      Dim uidoc As NotesUIDocument
      Dim varNames(49) As String
      Set s = New NotesSession
      Set db = s.CurrentDatabase
      Dim user As String
      user = s.UserName
      
      Dim dc As NotesDocumentCollection
      Set dc = db.UnprocessedDocuments
      
      Dim docA As NotesDocument
      Dim docB As NotesDocument
      Dim item As NotesItem
      Dim i As Integer
      
      On Error Resume Next
      
      Set docA = dc.GetFirstDocument
      For i = 1 To dc.Count
            Set docA = dc.GetNthDocument( i )
            If docA.form(0) = "conf_call_survey" Then
                  Set docB = db.CreateDocument
                  docB.form = "Memo"
                  varNames(0) = docA.name(0)
                  varNames(1) = docA.name_1(0)
.............
                  varNames(49) = docA.name_49(0)
                  docB.SendTo = varNames    
                  
            End If
            Set uidoc = ws.EditDocument( False, docB )
            uidoc.Gotofield("Subject")
            Call docA.Save(True, True)
      Next
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 63

Expert Comment

by:SysExpert
Comment Utility
You may need to create a basic memo form with the required fields in the DB since it apparently does not have one.

You could copy the from from a standard mail DB, but you only need 4 or 5 basic fields, not all the other junk in it.


I hope this helps !
0
 

Author Comment

by:jforget1
Comment Utility
I will give that a try.
0
 

Author Comment

by:jforget1
Comment Utility
Getting close, I have a form that is opening, I have an editable Subject field and a Body field I want the user to be able to add text to, but they are not coming up as items I can add to.             docB.Body = docA.Body does not work, how can I make it so those fields are ready for data entry?
0
 
LVL 63

Expert Comment

by:SysExpert
Comment Utility
Body has to be a richtext field.

You need to create the body using the richtext commands, since there is no previous body.

Your original request asked for a blank memo with just the body available, and the to: field filled.

What is not working ?

I hope this helps !
0
 

Author Comment

by:jforget1
Comment Utility
I just needed to have it open in edit mode, just need to add a send button now.
0
 
LVL 63

Expert Comment

by:SysExpert
Comment Utility
Copy the send button  from a standard Mail DB - memo form, or use it as a reference to create your own.

I hope this helps !
0
 
LVL 18

Expert Comment

by:marilyng
Comment Utility
You do not need to use the:   docB.form = "Memo"


remark out that statement and send the email, it will work without the form assignment.   What is happening is that the database is searching for a "memo" form in the current database.  If you like, add a "memo" form that has the required fields: from, sendto, copyto, bcc, subject, body... but, easist is to just remark out the docb.form = "memo"
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
IMHO it would have been a lot easier to just follow my earlier advice AND create the mail in your mail database. That datyabase can be opened with NotesDatabase.OpenMail...
0
 
LVL 18

Expert Comment

by:marilyng
Comment Utility
that, too, will work. :)
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
I like the "too"... ;-))
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now