Link to home
Start Free TrialLog in
Avatar of Jaziar
Jaziar

asked on

Script Not Sending Email

Does anyone see a reason this script is not sending a email out.  It has worked before, but today it is not working.

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")      
      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)
  ' 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
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Hi Jaziar,

I hav no idea why it doesn't work any more.

>   Set item = newDoc.GetFirstItem("SendTo")
>      item.Values = varNewTo


Why not just
    newDoc.SendTo= varNewTo

And what's in the log about the agent or the mail? Did the agent do the lines after the Send?

Cheers!
   Sjef
ASKER CERTIFIED SOLUTION
Avatar of p_partha
p_partha

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pbag
pbag

Is the agent running ? I mean is it processing the target documents?