Link to home
Start Free TrialLog in
Avatar of Jaziar
Jaziar

asked on

Script Sending out Attachments in the emails

This script is sending out all attachments in the form with the email.  I dont want it to do that.  I just want the message and the doclink.  But I am not sure where it is picking up the attachments to.

Sub Click(Source As Button)
      Dim ws As New NotesUIWorkspace
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim uiDoc As NotesUIDocument
      Dim doc As NotesDocument
      Dim mDoc As NotesDocument
      Dim rtitem As NotesRichTextItem
      Set uiDoc = ws.CurrentDocument
      Call uiDoc.Save
      Set doc = uiDoc.Document
      Set db = session.CurrentDatabase
      Set mDoc = New NotesDocument(db)
      If doc.NagMail(0) = "Yes" Then
            Set item = Doc.ReplaceItemValue("NagList", Doc.SendTo)
      End If
      If doc.ViewBy(0) = "Viewing Restricted (To: Recipients Only)" Then
            Set item= Doc.ReplaceItemValue("DocReaders", Doc.SendTo)
            Set Pitem=Doc.ReplaceItemValue("Private", "Private")      
            Call item.AppendToTextList(session.UserName)
      End If
      
      doc.CreateFlag = No      
      'Set db = session.CurrentDatabase
      'Set mDoc = New NotesDocument(db)
      
      Call doc.CopyAllItems(mDoc)      
      If doc.ViewBy(0) = "No Restrictions (All)" Then
            Set item = mDoc.GetFirstItem("DocReaders")
            Call item.AppendToTextList(mDoc.SendTo)
            Call item.AppendToTextList(session.UserName)
      End If
      'mDoc.Form = doc.Subject
      mDoc.Subject = doc.Subject      
      mDoc.Form = "Memo"
      mDoc.SourceDocument = doc.UniversalID
      mDoc.SenderList = session.CommonUserName      
      Set rtitem = New NotesRichTextItem(mDoc, "Body" )
      Call rtitem.AppendText( "Your Attention Has Been Requested.")
      Call rtitem.AddNewLine(1)      
      Call rtitem.AppendText( "Please Click the link below to view the action.")
      Call rtitem.AddNewLine(2)            
      Call rtitem.AppendDocLink(doc, "PS&SD Dev. Budget Database Link" )      
      Call mDoc.Send(True)
      Call uiDoc.Close(True)
End Sub

The Attachment Field is called RequestAttachments
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

The CopyAllItems does that. :) I think some other things can be removed as well, I commented them out, and you need to specify some SendTo somewhere.

Sub Click(Source As Button)
     Dim ws As New NotesUIWorkspace
     Dim session As New NotesSession
     Dim db As NotesDatabase
     Dim uiDoc As NotesUIDocument
     Dim doc As NotesDocument
     Dim mDoc As NotesDocument
     Dim rtitem As NotesRichTextItem
     Set uiDoc = ws.CurrentDocument
     Call uiDoc.Save
     Set doc = uiDoc.Document
     Set db = session.CurrentDatabase
     Set mDoc = New NotesDocument(db)
'     If doc.NagMail(0) = "Yes" Then
'          Set item = Doc.ReplaceItemValue("NagList", Doc.SendTo)
'     End If
'     If doc.ViewBy(0) = "Viewing Restricted (To: Recipients Only)" Then
'          Set item= Doc.ReplaceItemValue("DocReaders", Doc.SendTo)
'          Set Pitem=Doc.ReplaceItemValue("Private", "Private")    
'          Call item.AppendToTextList(session.UserName)
'     End If
     
'     doc.CreateFlag = No    
     'Set db = session.CurrentDatabase
     'Set mDoc = New NotesDocument(db)
     
'     Call doc.CopyAllItems(mDoc)    
'     If doc.ViewBy(0) = "No Restrictions (All)" Then
'          Set item = mDoc.GetFirstItem("DocReaders")
'          Call item.AppendToTextList(mDoc.SendTo)
'          Call item.AppendToTextList(session.UserName)
'     End If
     'mDoc.Form = doc.Subject
' added start
     mdoc.SendTo= doc.SendTo
' added end
     mDoc.Subject = doc.Subject    
     mDoc.Form = "Memo"
     mDoc.SourceDocument = doc.UniversalID
     mDoc.SenderList = session.CommonUserName    
     Set rtitem = New NotesRichTextItem(mDoc, "Body" )
     Call rtitem.AppendText( "Your Attention Has Been Requested.")
     Call rtitem.AddNewLine(1)    
     Call rtitem.AppendText( "Please Click the link below to view the action.")
     Call rtitem.AddNewLine(2)          
     Call rtitem.AppendDocLink(doc, "PS&SD Dev. Budget Database Link" )    
     Call mDoc.Send(True)
     Call uiDoc.Close(True)
End Sub
Avatar of Jaziar
Jaziar

ASKER

I need this logic still

     If doc.NagMail(0) = "Yes" Then
          Set item = Doc.ReplaceItemValue("NagList", Doc.SendTo)
     End If
     If doc.ViewBy(0) = "Viewing Restricted (To: Recipients Only)" Then
          Set item= Doc.ReplaceItemValue("DocReaders", Doc.SendTo)
          Set Pitem=Doc.ReplaceItemValue("Private", "Private")    
          Call item.AppendToTextList(session.UserName)
     End If
     
     doc.CreateFlag = No    
     'Set db = session.CurrentDatabase
     'Set mDoc = New NotesDocument(db)
     
'     Call doc.CopyAllItems(mDoc)    
'     If doc.ViewBy(0) = "No Restrictions (All)" Then
'          Set item = mDoc.GetFirstItem("DocReaders")
'          Call item.AppendToTextList(mDoc.SendTo)
'          Call item.AppendToTextList(session.UserName)
'     End If

this stuff controls my readers fields and my NagMail
You may just be able to do a doc.RemoveItem("$FILE") after the CopyAllItems call ... if that is what is holding your attachments.
Avatar of Jaziar

ASKER

that did not work - but please keep trying - I need to get this working
What's the logic for? It works on doc, and you don't save doc afterwards, so the changes you make are useless...
ASKER CERTIFIED SOLUTION
Avatar of mssturgeon
mssturgeon

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 Jaziar

ASKER

Yep that worked
Avatar of Jaziar

ASKER

The logic is

 If doc.NagMail(0) = "Yes" Then
'          Set item = Doc.ReplaceItemValue("NagList", Doc.SendTo)
'     End If

If they select yes and puts the SendTo names in the NagList Field

 If doc.ViewBy(0) = "Viewing Restricted (To: Recipients Only)" Then
          Set item= Doc.ReplaceItemValue("DocReaders", Doc.SendTo)
          Set Pitem=Doc.ReplaceItemValue("Private", "Private")    
          Call item.AppendToTextList(session.UserName)
     End If

This populates the readers field if the viewing is restricted

 If doc.ViewBy(0) = "No Restrictions (All)" Then
'          Set item = mDoc.GetFirstItem("DocReaders")
'          Call item.AppendToTextList(mDoc.SendTo)
'          Call item.AppendToTextList(session.UserName)
'     End If

This just leaves it set to [Everyone]

Not sure how they work but they do