OpenNTF.org - Bulk e-mail from a view
My Links (Not logged in)
Code Bin Search
 
Hosted by Prominic.NET
Rate This Code
5 - brilliant stuff
4 - very nice
3 - average
2 - needs work
1 - bad
   OpenNTF Code Bin
About This Code
Brief Description:
Bulk e-mail from a view 
Rating:
Not Rated Yet 
Contributor:
Andrew Jones 
Category:
Lotusscript 
Type:
 
Last Modified:
17 Jun 2002 
OpenNTF Disclaimer

All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.

Code / Description

Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doccol As NotesDocumentCollection
Dim doc As NotesDocument
Dim eaddress As Variant
Dim recipients () As Variant
Dim recipname As Variant
Dim docsselect As Integer
Dim j As Integer

j = 0

Set db = session.CurrentDatabase
Set view = db.GetView("your view")
Set doccol = db.UnprocessedDocuments
docsselect = doccol.Count

Redim recipients(docsselect - 1)

Set doc = doccol.GetFirstDocument
eaddress = doc.Email(0)
recipname = doc.Name(0)

Do While Not(doc Is Nothing)
** this code block just checks that the appropriate documents are selected
from the view. Obviously, the values here should match your needs.**

If doc.Form(0) <> "Candidate" Then
Msgbox("The document selected for " & recipname & " is not a contact sheet.
Please select a contact sheet.")
Exit Sub
End If
If eaddress = "" Then
Msgbox(recipname & " does not have an e-mail address. Please add one to their
contact sheet or remove them from the recipient list")
Exit Sub
End If
recipients(j) = eaddress
j = j + 1
Set doc = doccol.GetNextDocument(doc)

Loop



Call composeMail(recipients)


End Sub

Function composeMail(targetaddress As Variant)
Dim session As New NotesSession
Dim ws As New NotesUIWorkspace
Dim mailuidoc As NotesUIDocument
Dim doc As NotesDocument
Dim recipient As String
Dim srchserver As String
Dim srchfile As String
Dim tadrs As String
Dim k As Integer
Dim lastadrs As Integer

tadrs = ""
lastadrs = Ubound(targetaddress)

srchserver = session.GetEnvironmentString( "MailServer", True )
srchfile = session.GetEnvironmentString( "MailFile", True )


If srchserver = "" Or srchfile = "" Then

Msgbox("There is a problem with your Notes preferences.

Please contact your administrator")
Exit Function

End If

For k = 0 To lastadrs
tadrs = tadrs & targetaddress(k) & ", "
Next

Set mailuidoc = ws.ComposeDocument(srchserver, srchfile, "Memo")

Call mailuidoc.FieldSetText("EnterSendTo", tadrs)

Call mailuidoc.GoToField("Subject")
End Function
Usage / Example
 Comments

No documents found

 Add your comment!