Link to home
Start Free TrialLog in
Avatar of hreinart
hreinart

asked on

Agent (and special view) needed to send out mails

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.
- do a reply
- 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?
please respond


Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

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)
Forgot the @Unique:
   @Unique(@DbColumn("":""; ""; "Your $Inbox"; new_column_number))
Avatar of hreinart
hreinart

ASKER

thanks for the quick reply.

there is a barrierer sending out 1 mail to thousands of receipients.
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!
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)?
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.
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.
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

????

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...
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......
' 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
                  Set Me.m_noteGroupEntry = Me.m_dbLocalAddressBook.createdocument
                  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",_
                              RemoveDuplicates(OptimizeAddressArray(Arrayappend(Me.m_noteOptions.GetItemValue("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
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
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
ASKER CERTIFIED SOLUTION
Avatar of Jean Marie Geeraerts
Jean Marie Geeraerts
Flag of Belgium image

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