Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

Caturing Names

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
jforget1
Asked:
jforget1
  • 7
  • 6
  • 5
  • +1
1 Solution
 
Sjef BosmanGroupware ConsultantCommented:
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
 
Sjef BosmanGroupware ConsultantCommented:
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
 
SysExpertCommented:
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.

 
SysExpertCommented:
sjef is fast this morning.

0
 
Sjef BosmanGroupware ConsultantCommented:
Morning?? It's 17:28 over here... :-P
0
 
jforget1Author Commented:
I will work at getting these into my design this afternoon, I appreciate the quick response.
0
 
jforget1Author Commented:
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
 
SysExpertCommented:
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
 
jforget1Author Commented:
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
 
jforget1Author Commented:
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
 
SysExpertCommented:
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
 
jforget1Author Commented:
I will give that a try.
0
 
jforget1Author Commented:
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
 
SysExpertCommented:
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
 
jforget1Author Commented:
I just needed to have it open in edit mode, just need to add a send button now.
0
 
SysExpertCommented:
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
 
marilyngCommented:
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
 
Sjef BosmanGroupware ConsultantCommented:
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
 
marilyngCommented:
that, too, will work. :)
0
 
Sjef BosmanGroupware ConsultantCommented:
I like the "too"... ;-))
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 7
  • 6
  • 5
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now