• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 291
  • Last Modified:

Sending A Email in Script

here is the piece of code where I am getting names from a address book and then sending out a email to the picked names.

varNewTo = ws.PickListStrings(PICKLIST_NAMES, True)
k = Inputbox("Enter your comments")      
Set item = newDoc.GetFirstItem("SendTo")
item.Values = varNewTo
'newDoc.SenderList = "Forwarded by " & session.CommonUserName & Chr$(13) & newDoc.SenderList(0)
newDoc.Subject = "Fw: " & thisDoc.Subject(0)    
newDoc.FowardComments = k      
Call newDoc.Send(True)

Right now it only sends the email to the person in the SendTo Field.  Being I am not sure how Send works.  Am I assigning the PickLIST_NAMES correctly?
0
Jaziar
Asked:
Jaziar
  • 39
  • 26
  • 3
  • +1
1 Solution
 
madheeswarCommented:
dim item as notseitem
set item=curdoc.getfirstitem("SendTo")  'Assume Sento field is a Multi-value field.
For x=0 to ubound(item.values)
call newdoc.send(item.values(x),false)
next
0
 
Sjef BosmanGroupware ConsultantCommented:
What a waste, sending one mail many times, whilst you can have many names in the SendTo-field.

I suppose you select multiple names? Using Shift-click or Ctrl-click?

Suggested change:

    %include "lsconst.lss"

    varNewTo = ws.PickListStrings(PICKLIST_NAMES, True)
    k = Inputbox("Enter your comments")    
    newDoc.SendTo= varNewTo
    'newDoc.SenderList = "Forwarded by " & session.CommonUserName & Chr$(13) & newDoc.SenderList(0)
    newDoc.Subject = "Fw: " & thisDoc.Subject(0)    
    newDoc.FowardComments = k    
    Call newDoc.Send(True)

For the rest, it seems okay to me...
0
 
JaziarAuthor Commented:
Let me explain a little what is happening here

They user recieves a email and has the option to forward the email to other people.  When they click forward the picklist pops up and they can select as many names as they like.  Then the comments box pops up and they fill in a message to the forward users.  Then it should send a email to the people from the picklist.

The SendTo does all Multiple entries.

Sjef I tried your code but I am not sure how to include %include "lsconst.lss"
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
JaziarAuthor Commented:
Here is the complete code for the forward action - this may help

Sub Click(Source As Button)
      Dim ws As New NotesUIWorkspace
      Dim db As NotesDatabase
      Dim uiDoc As NotesUIDocument
      Dim thisDoc As NotesDocument
      Dim newDoc As NotesDocument
      Dim varNewTo As Variant
      Dim item As NotesItem
      Dim session As New NotesSession
      Dim view As NotesView
      Dim pDoc As NotesDocument
      Dim strServer As String
      Dim strFilename As String
      Dim rtItem As NotesRichTextItem
      Set uiDoc = ws.CurrentDocument
      Set thisDoc = uiDoc.Document
      Set db = thisDoc.ParentDatabase
      Dim strToName As String
      Set newDoc = New NotesDocument(db)
      Call thisDoc.CopyAllItems(newDoc, True)
      
      varNewTo = ws.PickListStrings(PICKLIST_NAMES, True)
      k = Inputbox("Enter your comments")    
      newDoc.SendTo= varNewTo
    'newDoc.SenderList = "Forwarded by " & session.CommonUserName & Chr$(13) & newDoc.SenderList(0)
      newDoc.Subject = "Fw: " & thisDoc.Subject(0)    
      newDoc.FowardComments = k    
      Call newDoc.Send(True)
      
' Now, put a note in the original database indicating that the document was forwarded.
      strServer = thisDoc.DatabaseServer(0)
      strFilename = thisDoc.DatabaseName(0)
      
      Set db = New NotesDatabase(strServer, strFilename)
      Set view = db.GetView("2005\Actions")
      Set pDoc = db.GetDocumentByUNID(thisDoc.SourceDocument(0))
      Set rtItem = pDoc.GetFirstItem("Comments")
      strToName = StringReplace(item.Text, "CN=", "")
      strToName = StringReplace(strToName, "/OU=Lex/O=Lexmark", "")
      Call rtItem.AppendText("Forwarded to " & strToName & " by " & session.CommonUserName)
      Call rtItem.AddNewLine(1)
      Call rtitem.appendtext("Forwarded Comment:  " & k)
      Call rtItem.AddNewLine(1)
      Call pDoc.Save(True, False)
      Call uiDoc.Close(True)
End Sub
0
 
JaziarAuthor Commented:
It almost seems like when you add multiple names it breaks - it only sends the email to the last name entered?
0
 
Sjef BosmanGroupware ConsultantCommented:
The %include should be in the form's Global section, in the Options.

As I said, I don't see any mistakes, must be a heavy case of brain deformation on my side...

If you check with the debugger, just before the Send, what does the field SenTo contain??

WIld guess: did you define the field SendTo on the form, and can it have multiple values? This shouldn't matter I think, but one ne'er knows.
0
 
JaziarAuthor Commented:
Is there anything in this script that is for only R6  - I am the only using R6 here and and maybe the R5 clients are not getting the mails?
0
 
JaziarAuthor Commented:
I just debugged and watched the values just before the

Call newDoc.Send(True)

item.Values was correct and all the names were in there.  After the document is saved all the names are in the SendTo Field.  But it seems like Call newDoc.Send(True) is sending the wrong Info.
0
 
Sjef BosmanGroupware ConsultantCommented:
Don't see anything out of the ordinary for R5... What's your server, and the Mail template you're using? You tired the debugger already?
0
 
JaziarAuthor Commented:
Yes the debugger looks ok - as stated before going in to the send all the info seems correct.
0
 
JaziarAuthor Commented:
Here is the strange part about it all.  I forward it to myself or add my name to picklist - I get the emails fine.  They can be 5 names in the picklist and I will be the only one to get it?
0
 
Sjef BosmanGroupware ConsultantCommented:
Check the log.nsf of your mail server, to see if mails were sent away. If you need a second guinea-pigs, you can use my mail address...
0
 
JaziarAuthor Commented:
I dont have access to the mail server.  I never get to see the log.nsf :(  I am heading to lunch thanks for staying woth me on this
0
 
JaziarAuthor Commented:
Bosman can write a little test script that only send emails to the picklist people and then you can test it and then I can try it on this database and see if it works here - Ill lift the points for your trouble.
0
 
Sjef BosmanGroupware ConsultantCommented:
Why don't you just try the following, e.g. in an agent:

    Dim ns As New NotesSession
    Dim db As NotesDatabase
    Dim mdoc As NotesDocument
    Dim sendto As Variant

    Set db= ns.CurrentDatabase
    Set mdoc= New NotesDocument(db)
    mdoc.Subject= "Test"
    Redim sendto(1) As String
    sendto(0)= "youraddress/Org"
    sendto(1)= "anotheraddress/Org"
    mdoc.SendTo= sendto
    mdoc.Body= "Just testing..."
    Call mdoc.Send(True)

By the way, you have FowardComments, and not FoRwardComments
0
 
qwaleteeCommented:
Hi sjef_bosman,

> Suggested change:
Your code is 100% the same as his, you just replace:
    Set item = newDoc.GetFirstItem("SendTo")
    item.Values = varNewTo
with
    newDoc.SendTo= varNewTo

Which is really the same thing.  Now, wait, you also add the %include... which means, you may be assuming his problem is that he does not have PICKLIST_NAMES defined.  But that clearly IS NOT his problem, as he says he IS able to pick at least one name.  The TRUE parameter sets up multiple selection.

Best regards,
qwaletee
0
 
qwaleteeCommented:
Jaziar,

>      varNewTo = ws.PickListStrings(PICKLIST_NAMES, True)
>      k = Inputbox("Enter your comments")    
>      newDoc.SendTo= varNewTo

How about replacing that with:
     newDoc.SendTo= ws.PickListStrings(PICKLIST_NAMES, True)
     k = Inputbox("Enter your comments")    
 
It SHOULD be the same, but just in case it has something to do with the varNewTo intermediate variable...


I also suspect it mayhave something to do with your copyAllItems.  What happens if you take that out for testing?


- qwaletee
0
 
Sjef BosmanGroupware ConsultantCommented:
My code is not necessarily the same. The GetFirstItem assumes the presence of the item, which probably is the case. My code bluntly overwrites SendTo if it is already there.

CopyAllItems... Could be, if there are special fields in the document.
0
 
JaziarAuthor Commented:
When I removed the CopyallItems

At the Call newDoc.Send(True) I get the error - no form associcated with document
0
 
JaziarAuthor Commented:
Here is what happening - You may be right about the copy

If the document was sent to me (so I am in the SendTo) and I then foward (picklist Joe)

Joe does not get a email

If I foward (picklist Joe and myself)

Joe does not get a email but I do

If I foward (picklist myself)

I get a email

It seems to either know who the SendTo person is or it has something to do with currentUser.


0
 
Sjef BosmanGroupware ConsultantCommented:
I don't know how the send-with-form is implemented, but apparently some evaluation of the form is done. If you remove the CopyAllItems, and you set the parameter to Send to False, what happens then?? Like
    Call newDoc.Send(False)
You won't send the form, but you could see to whom the mail would be sent.
0
 
JaziarAuthor Commented:
Marked out the Copy and set the send to False and yes the emails got sent out.  So I guess it is something with the copy.  DO you need more information on how the form works or why it is sending the form?
0
 
Sjef BosmanGroupware ConsultantCommented:
If you need all the form's field information, isn't it possible to copy only those fields? I can imagine the CopyAllFields might seem very practical, but you'll be copying a lot of internal fields as well. If there are many fields, you could try to use Split (if you have R6):

    Dim v As Variant

    v= Split("Field1;Field2;.....", ";") ' works like @Explode
    Forall vi In v
        Call doc.GetFirstItem(vi).CopyItemToDocument(newDoc)
    End Forall
0
 
JaziarAuthor Commented:
If I code this in R6, will it still work in a R5 client?
0
 
JaziarAuthor Commented:
I only have 16 fields on the form
0
 
Sjef BosmanGroupware ConsultantCommented:
There's no Split in R5... You could write out all the lines to fill an array, but I prefer my function.

A function that's equivalent to Split:

Function Eksplode(Byval r As String, s As String) As Variant
      Dim i As Integer
      Dim v As Variant
      Dim n As Integer

      Redim v(0)
      i= Instr(r,s)
      Do While i>0
            Redim Preserve v(n)
            v(n)= Left(r,i-1)
            r= Mid(r,i+Len(s))
            i= Instr(r,s)
            n= n+1
      Loop
      Redim Preserve v(n)
      v(n)= r
      Eksplode= v
End Function
0
 
JaziarAuthor Commented:
I have a meeting then I will try and put your function in.  I am assuming we will have to call the function in the action script - How would that look?
0
 
Sjef BosmanGroupware ConsultantCommented:
Huh? Instead of the CopyAllItems, you use the lines I gave earlier, with the Forall. The function above you can paste at the end of the agent, on the line below the End Sub.
0
 
JaziarAuthor Commented:
Bosman thanks for staying with me and responding quickly.  Here is a question I pretty sure I know but I want to make sure.
v= Split("Field1;Field2;.....", ";") ' works like @Explode

I need to add all my fields names correct

eg: v= Split("SendTo;Messages;.....", ";") ' works like @Explode

Is that correct?
0
 
JaziarAuthor Commented:
Dim v As Variant

    v= Split("Field1;Field2;.....", ";") ' works like @Explode
    Forall vi In v
        Call doc.GetFirstItem(vi).CopyItemToDocument(newDoc)
    End Forall

I also dont see where you are calling the Function
0
 
JaziarAuthor Commented:
Call doc.GetFirstItem(vi).CopyItemToDocument(newDoc)

Error not a sub or doc
0
 
Sjef BosmanGroupware ConsultantCommented:
Instead of Split use Eksplode :)
0
 
Sjef BosmanGroupware ConsultantCommented:
Omission:
    Call thisDoc.GetFirstItem(vi).CopyItemToDocument(newDoc)
0
 
JaziarAuthor Commented:
Here is what I have

                Set newDoc = New NotesDocument(db)
      'Call thisDoc.CopyAllItems(newDoc, True)
      v=Eksplode"DatabaseName;DatabaseServer;DatabaseTitle;Creator;PoopMessage;SenderList;Month;Title;RequestSecurity;RequestRequester;RequestDate;FowardComments;SendTo;Subject;Message;RequestAttachment") ' works like @Explode
      Forall vi In v
            Call thisDoc.GetFirstItem(vi).CopyItemToDocument(newDoc, "")
      End Forall
      
      newDoc.SendTo= ws.PickListStrings(PICKLIST_NAMES, True)
      k = Inputbox("Enter your comments")    
      Set item = newDoc.GetFirstItem("SendTo")
      'newDoc.SenderList = "Forwarded by " & session.CommonUserName & Chr$(13) & newDoc.SenderList(0)
      newDoc.Subject = "Fw: " & thisDoc.Subject(0)      
      Call newDoc.Send(True)

First Error

      Call thisDoc.GetFirstItem(vi).CopyItemToDocument(newDoc)
error ->Missing Argument for CopyItemToDocument so I add ""
               Call thisDoc.GetFirstItem(vi).CopyItemToDocument(newDoc, "")

Second Error

v= Eksplode("DatabaseName;DatabaseServer;DatabaseTitle;Creator;PoopMessage;SenderList;Month;Title;RequestSecurity;RequestRequester;RequestDate;FowardComments;SendTo;Subject;Message;RequestAttachment") ' works like @Explode
      
error ->Missing Argument for Eksplode

Should each Field have qoutes?
v= Eksplode("DatabaseName";"DatabaseServer"...........)


0
 
Sjef BosmanGroupware ConsultantCommented:
You missed the  , ";" at the end of Eksplode

The first error is my mistake, copyItem2doc needs a 2nd parameter indeed.
0
 
Sjef BosmanGroupware ConsultantCommented:
So
    Eksplode("DatabaseName;DatabaseServer;DatabaseTitle;Creator;PoopMessage;SenderList;Month;Title;RequestSecurity;RequestRequester;RequestDate;FowardComments;SendTo;Subject;Message;RequestAttachment", ";") ' works like @Explode
0
 
JaziarAuthor Commented:
Everything is working until I get to the Call newDoc.Send(True)

error -> No form associated with document
0
 
Sjef BosmanGroupware ConsultantCommented:
Ah, of course, you need to copy Form as well. There might be some other fields that have to be copied as well, we'll find out about those in due course.
0
 
JaziarAuthor Commented:
Sorry, but do I add newDoc/thisDoc to v=Eksplode"DatabaseName;DatabaseServer........

not sure how to include the form in the copy.  I am learning as we go, this is good stuff
0
 
Sjef BosmanGroupware ConsultantCommented:
That's the spirit!

No, you just have to addd the word Form to the list of fields to be copied, e.g.
    .....;RequestAttachment;Form", ";")
0
 
JaziarAuthor Commented:
Call thisDoc.GetFirstItem(vi).CopyItemToDocument(newDoc, "")

error -> object variable not set
0
 
JaziarAuthor Commented:
Grabbing a quick lunch - Thanks Bosman for everything so far - I have people waiting on this, so you are being a great help to me
0
 
Sjef BosmanGroupware ConsultantCommented:
Try this:
    Dim item As NotesItem

    Forall vi In v
        Set item= thisDoc.GetFirstItem(vi)
        If item Is Nothing Then
            Print "item " & vi & " doesn't exist"
        Else
            Call item.CopyItemToDocument(newDoc, "")
        End If
    End Forall        
0
 
qwaleteeCommented:
Dang, this thread stretches to the moon.
0
 
JaziarAuthor Commented:
A lot of newbie questions from Jaziar :)
0
 
Sjef BosmanGroupware ConsultantCommented:
Is that what you call a quick lunch? Then how long takes a "lengthy meal" ?? ;)

I think we're nearly there... Btw, it's nearly dinnertime for me, I'll be gone for an hour and a half.
0
 
JaziarAuthor Commented:
I get the form error again :(

I have to chew my food slowly so I can stay away from the office
0
 
JaziarAuthor Commented:
Ran through the debugger and it found every item in the function call except Form

Form went to the print section
not the else
0
 
Sjef BosmanGroupware ConsultantCommented:
So you have now
        v= Eksplode("DatabaseName;DatabaseServer;DatabaseTitle;Creator;PoopMessage;SenderList;Month;Title;RequestSecurity;RequestRequester;RequestDate;FowardComments;SendTo;Subject;Message;RequestAttachment;Form", ";") '
0
 
JaziarAuthor Commented:
Yes

When I run the debugger - That one Form shows up empty or null

welcome back :)
0
 
Sjef BosmanGroupware ConsultantCommented:
Then forget setting the form in the Eksplode-call, and just set Form as it should be, like
    newDoc.Form= "theformname"
0
 
Sjef BosmanGroupware ConsultantCommented:
Waitasecond, is the form already in the document?? Then you need to copy $Title, and not Form.
0
 
JaziarAuthor Commented:
The good news - No errors
The Bad News - No Emails

If I send it to Joe - nothing
If I send it to Joe and Jaziar - I get a emai
If I send it to Jaziar - I get it

Should I start removing fields one at a time from the function - to see which one is causing the problem>
0
 
JaziarAuthor Commented:
Hold on one sec - it may have done something
0
 
JaziarAuthor Commented:
It did send the emails to the people - but no form.

the email they got looks like Call newDoc.Send(True) is Call newDoc.Send(False)

But it is Call newDoc.Send(True)
 I just checked

0
 
JaziarAuthor Commented:
here is the code

                Dim v As Variant
      Set uiDoc = ws.CurrentDocument
      Set thisDoc = uiDoc.Document
      Set db = thisDoc.ParentDatabase
      Dim strToName As String
      Set newDoc = New NotesDocument(db)
      'Call thisDoc.CopyAllItems(newDoc, True)
=>Add      newDoc.Form= "Outgoing Request Form"
      v= Eksplode("DatabaseName;DatabaseServer;DatabaseTitle;Creator;PoopMessage;SenderList;Month;Title;RequestSecurity;RequestRequester;RequestDate;FowardComments;SendTo;Subject;Message;RequestAttachment", ";") ' works like @Explode
      Forall vi In v
            Set item= thisDoc.GetFirstItem(vi)
            If item Is Nothing Then
                  Print "item " & vi & " doesn't exist"
            Else
                  Call item.CopyItemToDocument(newDoc, "")
            End If
      End Forall        
      'Forall vi In v
      '      Call thisDoc.GetFirstItem(vi).CopyItemToDocument(newDoc, "")
      'End Forall
      
      newDoc.SendTo= ws.PickListStrings(PICKLIST_NAMES, True)
      k = Inputbox("Enter your comments")    
      Set item = newDoc.GetFirstItem("SendTo")
      'newDoc.SenderList = "Forwarded by " & session.CommonUserName & Chr$(13) & newDoc.SenderList(0)
      newDoc.Subject = "Fw: " & thisDoc.Subject(0)      
      Call newDoc.Send(True)
0
 
Sjef BosmanGroupware ConsultantCommented:
Different approach:
If the original form is okay, you can of course modify fields as you need them, then send the document, and finally throw the internal document away without saving it. So maybe you don't need to copy the document after all, just add or change some fields, send it and dump the changes. If you need the document afterwards in its original state, then reload it using GetDocumentByUnid

Is this feasible?
0
 
JaziarAuthor Commented:
Here is the way this thing is working

Inside the database a user creates a document (Request Form).
That action sends the Outgoing Response Form sent to the inboxes of users.  On this form you can reply to the orignal document or forward it to someone else.

When you reply it places the comment and a link to the response document in the first parent document.
If you forward it - it places a forward message in the parent document that it was forwarded and sends the form to the next user to reply or forwarded again.

So I am guessing the copy is getting field values for reference and the parent uniqueID for response reasons.  There are only 2 fields on the form that is editable.
When the forward action takes place there is no fields on the form that is editable - hence the comment thing added to the action.

So I have no clue how to handle this.

I need to be able to forward the form to multiple users and still be able to collect all responses in the parent docuement.  
0
 
JaziarAuthor Commented:
What I dont understand is if we assign
newDoc.Form= "Outgoing Request Form"
and newDoc.Send(True) - how can it be not sending the form?
0
 
Sjef BosmanGroupware ConsultantCommented:
I don't know. What might be required is that the form is stored to get it sent with the document. You could of course save the newDoc, send it and then delete it, but that's a lot of overhead. Try with the original document, modify some fields, DON'T SAVE it, send it and reload it.
0
 
JaziarAuthor Commented:
I am not sure we have to modify the form of the forward.  I think all we are doing is getting the values past to the form on create and sending it to the SendTo users specified in the PickList
Only time they edit is a reply action - which is seperate and works fine.

I am at a lost and must leave for the evening.  I am going to increase the points, becuase this as well as the other 500 pointer have became very critical to my manager.

Seems like it would be so simple to copy the form send it to the people from the picklist.  Anyclue why the copyall is breaking the SendTo?
0
 
Sjef BosmanGroupware ConsultantCommented:
Can you post your current code? I'll try to change it for you, using the idea I had.
0
 
JaziarAuthor Commented:
Forward Action

Sub Click(Source As Button)
      Dim ws As New NotesUIWorkspace
      Dim db As NotesDatabase
      Dim uiDoc As NotesUIDocument
      Dim thisDoc As NotesDocument
      Dim newDoc As NotesDocument
      Dim varNewTo As Variant
      Dim item As NotesItem
      Dim session As New NotesSession
      Dim view As NotesView
      Dim pDoc As NotesDocument
      Dim strServer As String
      Dim strFilename As String
      Dim rtItem As NotesRichTextItem
      Dim v As Variant
      Set uiDoc = ws.CurrentDocument
      Set thisDoc = uiDoc.Document
      Set db = thisDoc.ParentDatabase
      Dim strToName As String
      Set newDoc = New NotesDocument(db)
      'Call thisDoc.CopyAllItems(newDoc, True)
      'Set newDoc = uiDoc.Document
      newDoc.Form= "Outgoing Request Form"
      v= Eksplode("DatabaseName;DatabaseServer;DatabaseTitle;Creator;PoopMessage;SenderList;Month;Title;RequestSecurity;RequestRequester;RequestDate;FowardComments;SendTo;Subject;Message;RequestAttachment", ";") ' works like @Explode
      Forall vi In v
            Set item= thisDoc.GetFirstItem(vi)
            If item Is Nothing Then
                  Print "item " & vi & " doesn't exist"
            Else
                  Call item.CopyItemToDocument(newDoc, "")
            End If
      End Forall        
      newDoc.SendTo= ws.PickListStrings(PICKLIST_NAMES, True)
      k = Inputbox("Enter your comments")    
      Set item = newDoc.GetFirstItem("SendTo")
      'newDoc.SenderList = "Forwarded by " & session.CommonUserName & Chr$(13) & newDoc.SenderList(0)
      newDoc.Subject = "Fw: " & thisDoc.Subject(0)      
      Call newDoc.Send(True)
      
' Now, put a note in the original database indicating that the document was forwarded.
      strServer = thisDoc.DatabaseServer(0)
      strFilename = thisDoc.DatabaseName(0)
      
      Set db = New NotesDatabase(strServer, strFilename)
      Set view = db.GetView("2005\Actions")
      Set pDoc = db.GetDocumentByUNID(thisDoc.SourceDocument(0))
      Set rtItem = pDoc.GetFirstItem("Comments")
      strToName = StringReplace(item.Text, "CN=", "")
      strToName = StringReplace(strToName, "/OU=Lex/O=Lexmark", "")
      Call rtItem.AppendText("Forwarded to " & strToName & " by " & session.CommonUserName)
      Call rtItem.AddNewLine(1)
      Call rtitem.appendtext("Forwarded Comment:  " & k)
      Call rtItem.AddNewLine(1)
      Call pDoc.Save(True, False)
      Call uiDoc.Close(True)
End Sub

String Replace Function
Function StringReplace(strWhole As String, strFind As String, strReplace As String) As String
      Dim strOrig As String
      Dim strFirst As String
      Dim strLast As String
      Dim intPlace As Integer
      Dim intFindLength As Integer
      Dim intWholeLength As Integer
      
      strOrig = strWhole
      intPlace = Instr(strReplace, strFind)
      If (intPlace = 0) Or (strReplace = "") Then
          ' Perform the conversion
            intFindLength = Len(strFind)
            intPlace = Instr(strOrig, strFind)
            Do While (intPlace >< 0)
                  intWholeLength = Len(strOrig)
                  strFirst = Left$(strOrig, (intPlace - 1))
                  strLast = Right$(strOrig, intWholeLength - (intPlace + intFindLength) + 1)
                  strOrig = strFirst & strReplace & strLast
                  intPlace = Instr(strOrig, strFind)
            Loop
      End If
      StringReplace = strOrig
End Function

Eksplode Function

Function Eksplode(Byval r As String, s As String) As Variant
      Dim i As Integer
      Dim v As Variant
      Dim n As Integer
      
      Redim v(0)
      i= Instr(r,s)
      Do While i>0
            Redim Preserve v(n)
            v(n)= Left(r,i-1)
            r= Mid(r,i+Len(s))
            i= Instr(r,s)
            n= n+1
      Loop
      Redim Preserve v(n)
      v(n)= r
      Eksplode= v
End Function
0
 
Sjef BosmanGroupware ConsultantCommented:
thisDoc is never saved, you you can mutilate it any way you want, just don't ever save it!
You could think of setting SaveOptions to "0" explicitly

Save your old code somewhere (e.g. rename the agent) and read and test this code...

Sub Click(Source As Button)
     Dim ws As New NotesUIWorkspace
     Dim db As NotesDatabase
     Dim uiDoc As NotesUIDocument
     Dim thisDoc As NotesDocument
     Dim newDoc As NotesDocument
     Dim varNewTo As Variant
     Dim item As NotesItem
     Dim session As New NotesSession
     Dim view As NotesView
     Dim pDoc As NotesDocument
     Dim strServer As String
     Dim strFilename As String
     Dim rtItem As NotesRichTextItem
     Dim v As Variant

     Set uiDoc = ws.CurrentDocument
     Set thisDoc = uiDoc.Document
     Set db = thisDoc.ParentDatabase
     Dim strToName As String
     thisDoc.SendTo= ws.PickListStrings(PICKLIST_NAMES, True)
     k = Inputbox("Enter your comments")    
     Set item = thisDoc.GetFirstItem("SendTo")
     'newDoc.SenderList = "Forwarded by " & session.CommonUserName & Chr$(13) & newDoc.SenderList(0)
     thisDoc.Subject = "Fw: " & thisDoc.Subject(0)    
     Call thisDoc.Send(True)
' Now, put a note in the original database indicating that the document was forwarded.
     strServer = thisDoc.DatabaseServer(0)
     strFilename = thisDoc.DatabaseName(0)
     
     Set db = New NotesDatabase(strServer, strFilename)
     Set view = db.GetView("2005\Actions")
     Set pDoc = db.GetDocumentByUNID(thisDoc.SourceDocument(0))
     Set rtItem = pDoc.GetFirstItem("Comments")
     strToName = StringReplace(item.Text, "CN=", "")
     strToName = StringReplace(strToName, "/OU=Lex/O=Lexmark", "")
     Call rtItem.AppendText("Forwarded to " & strToName & " by " & session.CommonUserName)
     Call rtItem.AddNewLine(1)
     Call rtitem.appendtext("Forwarded Comment:  " & k)
     Call rtItem.AddNewLine(1)
     Call pDoc.Save(True, False)
     Call uiDoc.Close(True)
End Sub

Function StringReplace(strWhole As String, strFind As String, strReplace As String) As String
     Dim strOrig As String
     Dim strFirst As String
     Dim strLast As String
     Dim intPlace As Integer
     Dim intFindLength As Integer
     Dim intWholeLength As Integer
     
     strOrig = strWhole
     intPlace = Instr(strReplace, strFind)
     If (intPlace = 0) Or (strReplace = "") Then
          ' Perform the conversion
          intFindLength = Len(strFind)
          intPlace = Instr(strOrig, strFind)
          Do While (intPlace >< 0)
               intWholeLength = Len(strOrig)
               strFirst = Left$(strOrig, (intPlace - 1))
               strLast = Right$(strOrig, intWholeLength - (intPlace + intFindLength) + 1)
               strOrig = strFirst & strReplace & strLast
               intPlace = Instr(strOrig, strFind)
          Loop
     End If
     StringReplace = strOrig
End Function

0
 
JaziarAuthor Commented:
Still no emails to anyone other than the person clicking forward(only if they include themselves in the picklist)
0
 
JaziarAuthor Commented:
I am taking a quick lunch - be back
0
 
Sjef BosmanGroupware ConsultantCommented:
is there a field sendto on the form?? is it multi-value? Otherwise I'm stunned and have no more ideas... :'(
0
 
JaziarAuthor Commented:
There is a SendTo field and it is multi-value :( seperated on comma I think
0
 
JaziarAuthor Commented:
Should I repost the question?  Let some new eyes look at the problem.  I have earned these points bosman, but like you I have no clue how to fix it.

What in the form could block the mail send?
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 39
  • 26
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now