Sending mail to selected documents in a view

Hey All- I need to be able to select a bunch of documents in a View and do a mail send to the selected documents. I know how to do this with either a Simple action and then call the Agent with @Command([ToolsRunMacro]; which will process all the selected documents or do an @ Mailsend etc. However, what I don’t know how do is to be able to have the agent flexible enough so that someone on the fly can select a bunch of documents in a view and then before doing some sort of “Mail Send”, be prompted to put in whatever they want to say to the end users. So if I wanted to tell a bunch of users we were going to convert there mail on “Thursday” or whatever, I can go into the view, select a whole bunch of random documents then send and e-mail but before the message goes out I get prompted to put the message/information in I want to send to them before it actually goes. Has anyone done something like this?

Thx

Tom

Subject: Sending mail to selected documents in a view

Well in the ND6.5 DD there was an action to do this. Not sure if it’s still in the ND7 DD design or not but check. Open the People view and there may be a button on the right in the action bar titled “Send Upgrade Notifications”. Check the code behind the button to see how it’s done. Pretty simple. There’s also a “Write Memo” button in the Contacts voew in the Personal Address Book that will compose a memo to selected users. You may be able to incorporate that as well.

Subject: Answered to this: Sending mail to selected documents in a view

I’m answering my own question.

Sub Initialize

        Dim ns As New NotesSession

        Dim db As NotesDatabase

        Dim doc As NotesDocument

        Dim dc As NotesDocumentCollection

        Dim email As NotesDocument

        Dim rtitem As NotesRichTextItem

        Dim message As String

        Dim subject As String

        

        Set db = ns.CurrentDatabase

        

        Set dc  = db.UnprocessedDocuments

        Set doc = dc.GetFirstDocument

        

        subject = Inputbox$("What is the subject?????")

        message = Inputbox$("What is the message?????")

        

        Do While Not doc Is Nothing

                    Set email = New NotesDocument(db)

                    Set rtitem=New NotesRichTextItem(email,"Body")

                    email.Form = "Memo"

                    email.Subject = subject

                    email.SendTo = "The field you want to draw an e-mail adress from"

                    Call rtitem.appendtext(message)

                    Call email.Send (True )   

                    Set doc = dc.GetNextDocument(doc)

        Loop

Also, you need to make and agent using @Command([ToolsRunMarco]; “agent you made with above code”).

Subject: Sending mail to selected documents in a view

What you want to do can be achieved, I’ve done something similar in LotusScript.

First you get the collection corresponding to all the selected documents in a view.

Dim session As New NotesSession

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument

dim mail as NotesDocument

dim rtBody as NotesRichTextItem

dim strMessage as string, strSubject as string

Set db = session.CurrentDatabase

Set collection = db.UnprocessedDocuments

Set doc = collection.GetFirstDocument()

strSubject = inputbox(“Subject of the mail?”)

strMessage = inputbox(“Body of the mail?”)

While Not(doc Is Nothing)

Set mail = db.createdocument

With mail

.form = “Memo”

.SendTo = doc.EmailField(0) 'email address of the user

.Principal = “your email address goes here, this is the email address the users will see as sender”

.Subject = strSubject

End With

set rtBody = mail.createrichtextitem(“Body”)

call rtBody.appendText(strMessage)

call mail.send(false)

set mail = nothing

Set doc = collection.GetNextDocument(doc)

Wend

this roughly describes the process

I suppose you could write an agent (targets only selected documents) that prompts for message/information. This probably would be a better way to do it because you could use it in any view you want(using the Actions menu).

Hope this helps

Remi