Go Premium for a chance to win a PS4. Enter to Win

x
Solved

# Agent (and special view) needed to send out mails

Posted on 2003-10-28
Medium Priority
382 Views
hi,

i need an agent sending out a mail to everyone who appears in my inbox.

idea:
i need a new view, similar to the inbox folder, showing incomming mails.
i don't want to see duplicate sender addresses. so something like "unique" on from / replyto ...or what ever is good to use here.

then i need an agent  going from the first mail until to the last mail and create per incomming mail a new mail (regarding the subject: not a real reply).
the agent should do this:
- so imagine looking at your inbox.
- sort it e.g. by date. go to the 1st mail.
- change the subject to "this my special mail"
- put some predefined text (not person specific) into the body
- press send-only
- goto the next mail...and so on
- ....and all this in the special unique view

if this  works it would look like this:
- i open a new view or folder
- i see all mails beeing sent to me sofar from all senders
- if a sender writes 3 mails to me, i only see 1 of them
- i press "agent xxx run"
- the agent will create some thousand mails with a spcific subject and body.

anything unclear?

0
Question by:hreinart

LVL 46

Expert Comment

ID: 9635339
You don't need an agent for this. Why don't you put all your addresses into the BCC at once, so they won't see each other's mail address? It's just one mail then. All addresses you can get by making a copy of the ($Inbox) folder and adding a column filled with From, and then using @DbColumn("":""; ""; "Your$Inbox"; new_column_number)
0

LVL 46

Expert Comment

ID: 9635353
Forgot the @Unique:
@Unique(@DbColumn("":""; ""; "Your $Inbox"; new_column_number)) 0 Author Comment ID: 9635473 thanks for the quick reply. there is a barrierer sending out 1 mail to thousands of receipients. 0 LVL 46 Expert Comment ID: 9636409 There's even a better approach maybe (with an agent...). In the mail-database (R6) there is an action Add Recipients\to new Group in Address Book. You could copy this agent and modify it to Add Originators\to new Group in Address Book. Inside the Declaration section there is a function ProcessCandidates(), with 4 times almost identical lines (SendTo, CopyTo, etc). You could modify this one to read ... If Me.m_noteCandidate.hasitem("From") And Len(Me.m_noteCandidate.GetItemValue("From")(0)) Then Me.m_strRecipientArray = Arrayappend(Me.m_strRecipientArray,AppendDomain(Me.m_noteCandidate.GetItemValue("SendTo"))) End If ... Maybe there are even more things to change, but you could test this with only a few mails selected. If you have created the group in your N&A-book, you can put this group into the BCC of your mail. Good luck! 0 LVL 31 Expert Comment ID: 9637615 Are you talking about sending a message to every person who has ever sent you a message? Or only to those that are currently in your inbox (those that you have not deleted and not moved to a different folder)? 0 Author Comment ID: 9640289 sjef_bosman: i'm using r5, sorry didn't mention it. i'm looking for a complete solution, i can't program qwaletee: i'm laszy .... ;-) nearly all people who wrote me a mail are (still) in my inbox. so this would work, if you have something running on this (or duplicate) view. 0 LVL 46 Expert Comment ID: 9642583 R5? I don't know if I still have that template... same Action is there, probably also the same coding. But if you cannot program, do you have the Notes Designer or what? How do you plan to do the necessary coding? I tested it for you, and it works just as I described above. Your recipe: 1. View the Design of your mail database 2. go to the Agents 3. make a copy of Add Recipients\to new Group in Address Book 4. name this one Add Senders\... 5. go to Declarations 6. look for the function ProcessCandidates 7. look for the 2 lines with SendTo 8. replace all words SendTo by From 9. throw away 6 lines starting with If Me.m_noteCandidate.hasitem("CopyTo") 10. save, close, goto Notes, Actions, and click your new Action You then create a new group in your N&A-book. 0 Author Comment ID: 9643308 sjef_bosman: i have a desinger. if i do all what you tested, what can i do with the new group in my n&a? ok, i can't do it, but is it really so complicate to write an agent doing: - go to the 1st document in the view or folder - create a reply - change subject to: xxxx - change body to: yyyy - send the mail without saving locally ???? 0 LVL 46 Expert Comment ID: 9643738 Okay, you added the agent, did you activate it? It asked you to type the name of a group, and after the OK it created this group for you in you personal N&A Book. Is that right, is there a new group? If so, you can just write one new mail, name the group in the BCC and press send. That should be all. If you think you have too many names in the group, split it up into several groups and send more mails. Whether writing an agent is complicated depends on the person you're asking it from. It takes quite some time, which I haven't go (or don't want to spend for free). Helping you is no problem, but I'm not going to lead you all the way. Be a sport, do try it for yourself... 0 Author Comment ID: 9643862 hi, i wonder why you always reply to the questions and write: i don't have time for it. if you don't have time, please don't reply. i need a solution, that's why i ask here...and normally get the needed answers. splitting up in groups is not what i want. i don't want to count until (about) 250 recipients and go for the next 250... i need that solution that creates one mail after the other (or 1 mail with 249 bcc receipients). nichts für ungut, aber alles andere bringt mir nichts...... 0 LVL 46 Expert Comment ID: 9644300 ' Agent Add Senders\to new Group in Address Book Use "Common" Option Declare Class AddToGroupStringTable Function GetString(nIndex As Integer, vData As Variant) As String Select Case nIndex Case 1 GetString = "Rename target group" Case 2 GetString = "Replace existing group with new group" Case 3 GetString = "Append selected member(s) to existing group member(s)" Case 4 GetString = "A group by this name is already defined. " Case 5 GetString = "Please select the desired action" Case 6 GetString = "Please enter new group name" Case 7 GetString = "Lotus Notes" Case 8 GetString = "-Untitled-" Case 9 GetString = "Add recipients to new group" End Select End Function End Class Class GroupHelperLauncher As BaseApplication Private m_GroupHelperStringTable As AddToGroupStringTable Private m_uiws As notesuiworkspace Private m_dbLocalAddressBook As notesdatabase Private m_viewGroup As notesview Private m_collection As notesdocumentcollection Private m_noteOptions As notesdocument Private m_noteCandidate As notesdocument Private m_noteGroupEntry As notesdocument Private m_vUserDomain As Variant Private m_vTrimmedList As Variant Private m_strRecipientArray As Variant Private m_nSuccess As Integer Private m_nEntryNumber As Integer '//Public Subs and Functions '//Init// Sub Init() Set Me.m_GroupHelperStringTable = New AddToGroupStringTable Set Me.m_collection = GroupHelperLauncher..DocumentsToProcess If Not Me.m_collection.count > 0 Then Exit Sub End If Set Me.m_uiws = New notesuiworkspace Me.m_vUserDomain = Evaluate(|@Domain|) Set Me.m_dbLocalAddressBook = GroupHelperLauncher..LocalAddressBook Set Me.m_noteOptions = Me.m_db.CreateDocument End Sub Function ProcessCandidates() Set Me.m_noteCandidate = Me.m_collection.getfirstdocument While Not Me.m_noteCandidate Is Nothing If Not Isarray(Me.m_strRecipientArray) Then Redim Me.m_strRecipientArray(0) Me.m_strRecipientArray(0) = "" Else Me.m_nEntryNumber = Me.m_nEntryNumber + 1 End If If Me.m_noteCandidate.hasitem("From") And Len(Me.m_noteCandidate.GetItemValue("From")(0)) Then Me.m_strRecipientArray = Arrayappend(Me.m_strRecipientArray,AppendDomain(Me.m_noteCandidate.GetItemValue("From"))) End If Set Me.m_noteCandidate = Me.m_collection.getnextDocument(Me.m_noteCandidate) Wend Me.m_vTrimmedList = RemoveDuplicates(OptimizeAddressArray(Me.m_strRecipientArray)) Call Me.m_noteOptions.replaceitemvalue("AllAddresses",Me.m_vTrimmedList) Me.m_nSuccess = Me.m_uiws.dialogbox("(GroupHelper)",True,True,False,False,False,False,_ Me.m_GroupHelperStringTable.GetString(9,Null),Me.m_noteOptions,True,False) If Me.m_nSuccess Then Call CreateNABEnrty() End If End Function Private Function AppendDomain(EmailAddessArray As Variant) As Variant If Me.m_noteCandidate.hasitem("FromDomain") Then If Len(Me.m_noteCandidate.GetItemValue("FromDomain")(0)) Then Dim x As Integer For x = 0 To Ubound(EmailAddessArray) If Not EmailAddessArray(x) = "" And Not Isnull(EmailAddessArray(x)) Then If Not Me.m_vUserDomain(0) = Me.m_noteCandidate.GetItemValue("FromDomain")(0) Then EmailAddessArray(x) = EmailAddessArray(x) & "@" & Me.m_noteCandidate.GetItemValue("FromDomain")(0) End If End If Next End If End If AppendDomain = EmailAddessArray End Function Private Function OptimizeAddressArray(EmailAddress As Variant) As Variant On Error Goto TRAP If Isarray(EmailAddress) Then Dim x As Integer Dim vTempName As Variant For x = 0 To Ubound(EmailAddress) If Not EmailAddress(x) = "" Or Not Isnull(EmailAddress(x)) Then vTempName = Evaluate(|@OptimizeMailAddress("| & EmailAddress(x) &|")|) EmailAddress(x) = vTempName(0) End If Next Else EmailAddress = Evaluate(|@OptimizeMailAddress("| & EmailAddress &|")|) End If OptimizeAddressArray = EmailAddress Exit Function TRAP: vTempName(0) = EmailAddress(x) Resume Next End Function Function RemoveDuplicates(strArray As Variant) As Variant Dim x As Integer Dim y As Integer Dim tmpstrArray() As String Redim tmpstrArray(0) For x = 0 To Ubound(strArray) If Isnull(Arraygetindex(tmpstrArray,strArray(x),1)) Then tmpstrArray(y) = strArray(x) y = y+1 Redim Preserve tmpstrArray(y) End If Next RemoveDuplicates = Fulltrim(tmpstrArray) End Function Function CreateNABEnrty() Set Me.m_viewGroup = Me.m_dbLocalAddressBook.GetView("($PeopleGroupsFlat)")
Set Me.m_noteGroupEntry = Me.m_viewGroup.Getdocumentbykey(Me.m_noteOptions.GroupName(0),True)
If Me.m_noteGroupEntry Is Nothing Then
'// this is a new group and we'll just populate it
With Me.m_noteGroupEntry
Call .replaceitemvalue("Form","Group")
Call .replaceitemvalue("Type","Group")
Call .replaceitemvalue("ListName",Me.m_noteOptions.GetItemValue("GroupName"))
Call .replaceitemvalue("GroupType",Me.m_noteOptions.GetItemValue("GroupType"))
Call .replaceitemvalue("ListDescription", Me.m_noteOptions.GetItemValue("Description"))
Call .replaceitemvalue("Members", Me.m_noteOptions.GetItemValue("SelectedGroupMembers"))
Call .save(True,True,True)
End With
Else
'// this group is already in the NAB, so lets see what they want to do!
Dim Options(2) As String
Dim strResponse As String
Options(0) = Me.m_GroupHelperStringTable.GetString(1,Null)
Options(1) = Me.m_GroupHelperStringTable.GetString(2,Null)
Options(2) = Me.m_GroupHelperStringTable.GetString(3,Null)
strResponse = Me.m_uiws.Prompt(prompt_okcancellist,_
Me.m_GroupHelperStringTable.GetString(7,Null),_
Me.m_GroupHelperStringTable.GetString(4,Null) & Chr(13) & _
Me.m_GroupHelperStringTable.GetString(5,Null),_
Options(0), Options)

Select Case strResponse

Case Options(0)
'get new group string name from user
Dim strtmpGroupString As String
strtmpGroupString = Inputbox(Me.m_GroupHelperStringTable.GetString(6,Null),_
Me.m_GroupHelperStringTable.GetString(7,Null),_
Me.m_GroupHelperStringTable.GetString(8,Null))
Call Me.m_noteOptions.replaceitemvalue("GroupName",strtmpGroupString)
Call CreateNABEnrty()
Case Options(1)
'replace the members
With Me.m_noteGroupEntry
Call .replaceitemvalue("GroupType",Me.m_noteOptions.GetItemValue("GroupType"))
Call .replaceitemvalue("Members", Me.m_noteOptions.GetItemValue("SelectedGroupMembers"))
Call .save(True,True,True)
End With
Case Options(2)
'append the members to the list (check for unique entries)
With Me.m_noteGroupEntry
Call Me.m_noteOptions.ReplaceItemValue("SelectedGroupMembers",_
.GetItemValue("Members")))))
Call .replaceitemvalue("Members", Me.m_noteOptions.GetItemValue("SelectedGroupMembers"))
Call .save(True,True,True)
End With
End Select
End If
End Function
End Class

Sub Initialize
Dim copyfunction As New GroupHelperLauncher
Call copyfunction.init()
Call copyfunction.ProcessCandidates()
End Sub

' Und jetzt genügt's, ich werde nie wieder reagieren auf so eine Frage
0

Author Comment

ID: 9644426
ups.. looks interesting, thanks sofar.

it'd be nice if you could give me some (even short) comments) where to insert this.
will this agent work like i asked?

i'll have to try it out.

thanks
hreinart
0

Author Comment

ID: 9669499
sjef_bosman:

hi,

i don't understand what you wrote.
could you please put it in a database and mail it to:
nospamforhreinart@onlinehome.de

this account will work about 1 pm 11-03-2003

thanks
hreinart
0

LVL 8

Accepted Solution

Jean Marie Geeraerts earned 400 total points
ID: 9693998
Well, this is actually not all that complicated.
Since you want to send the same mail to everybody in your inbox, all you need to do is first get all the addressees from your inbox, make sure all names in the list are unique and then create the mail for all the addressees.

Here's what to do:
1) Create an agent with the following properties:
- Run 'Manually from agent list'
- Run on 'All Documents in view'
- Use 'LotusScript'
2) Call this agent from your inbox and it will do what you want, no extra view needed. If there are people you don't want included, move them to another folder before running the agent.

The code for the agent :
Sub Initialize
'Define body text
Const BODY_TEXT = {Enter any text you want included in your mail here.
You can enter a new paragraph, by just starting the text on a new line here. Just make sure all text is located between the two curly brackets.
}
' initialize variables
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim docIn As NotesDocument
Dim docOut As NotesDocument
Dim i As Integer
Dim strMacro As String
Dim rtBody As NotesRichTextItem

'get reference to database and documents in the current view
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
If dc.Count = 0 Then
Messagebox "No documents in view"
Exit Sub
End If

'initialize array to hold all names from the documents in the view

'walk through all documents in the view and add the names to the array
i = 0
Set docIn = dc.GetFirstDocument
Do While Not docIn Is Nothing
Set docIn = dc.GetNextDocument(docIn)
i = i + 1
Loop

'for this we call @Unique function and pass it the list of all names
strMacro = {@Unique("} & StrImplode(strAddressees, {":"}) & {")}

'create a new document for all addressees
Set docOut = db.CreateDocument
With docOut
.SendTo = a
Set rtBody = .CreateRichTextItem("Body")
End With
Call rtBody.AppendText(BODY_TEXT)
'Send the document without atttaching the form to the recipient in SendTo field
Call docOut.Send(False)
End Forall
End Sub

Function StrImplode(array As Variant, strDelimiter As String) As String
'This functon is the LS equivalent to @Implode
'It  takes an array of strings (=array) and combines it to one string, with a fixed delimiter (=strDelimiter)

Dim i As Integer
StrImplode = ""
Dim last As Integer
last = Ubound(array)
For i = 0 To (last - 1)
StrImplode = StrImplode + array(i) + strDelimiter
Next
StrImplode = StrImplode + array(last)
End Function

If you have any problems implementing the code, just let me know.

Kind Regards,
JM
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Loops Section Overview
###### Suggested Courses
Course of the Month10 days, 7 hours left to enroll