Solved

Caturing Names

Posted on 2006-11-14
20
217 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
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
 
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 500 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

912 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

16 Experts available now in Live!

Get 1:1 Help Now