jforget1
asked on
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.DateTimeVa lue
Call installDate.SetAnyTime
Call docB.ReplaceItemValue("dat e",install Date)
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
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.DateTimeVa
Call installDate.SetAnyTime
Call docB.ReplaceItemValue("dat
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
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.??
varNames(0) = docA.name(0)
varNames(1) = docA.name_1(0)
varNames(2) = docA.name_2(0)
etc.??
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
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
sjef is fast this morning.
Morning?? It's 17:28 over here... :-P
ASKER
I will work at getting these into my design this afternoon, I appreciate the quick response.
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
ASKER
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
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
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 !
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 !
ASKER
I will give that a try.
ASKER
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?
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 !
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 !
ASKER
I just needed to have it open in edit mode, just need to add a send button now.
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 !
I hope this helps !
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"
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"
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...
that, too, will work. :)
I like the "too"... ;-))
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.