Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Caturing Names

Posted on 2006-11-14
20
Medium Priority
?
227 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
  • 5
  • +1
20 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17939143
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
ID: 17939156
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
ID: 17939169
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 63

Expert Comment

by:SysExpert
ID: 17939178
sjef is fast this morning.

0
 
LVL 46

Expert Comment

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

Author Comment

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

Author Comment

by:jforget1
ID: 17957343
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 2000 total points
ID: 17957418
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
ID: 17958298
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
ID: 17958674
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
 
LVL 63

Expert Comment

by:SysExpert
ID: 17959375
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
ID: 17959419
I will give that a try.
0
 

Author Comment

by:jforget1
ID: 17959512
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
ID: 17959790
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
ID: 17959916
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
ID: 17959978
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
ID: 17961502
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
ID: 17963565
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
ID: 17969657
that, too, will work. :)
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17970869
I like the "too"... ;-))
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

722 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