Solved

Agent (and special view) needed to send out mails

Posted on 2003-10-28
14
369 Views
Last Modified: 2013-12-18
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


0
Comment
Question by:hreinart
14 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
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

by:Sjef Bosman
Comment Utility
Forgot the @Unique:
   @Unique(@DbColumn("":""; ""; "Your $Inbox"; new_column_number))
0
 

Author Comment

by:hreinart
Comment Utility
thanks for the quick reply.

there is a barrierer sending out 1 mail to thousands of receipients.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
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

by:qwaletee
Comment Utility
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

by:hreinart
Comment Utility
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

by:Sjef Bosman
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:hreinart
Comment Utility
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

by:Sjef Bosman
Comment Utility
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

by:hreinart
Comment Utility
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

by:Sjef Bosman
Comment Utility
' 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
0
 

Author Comment

by:hreinart
Comment Utility
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

by:hreinart
Comment Utility
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

by:
Jean Marie Geeraerts earned 100 total points
Comment Utility
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 strAddressees() As String
      Dim varUniqueAddressees As Variant
      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
      Redim strAddressees(dc.Count-1)
      
      '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
            strAddressees(i) = docIn.From(0)
            Set docIn = dc.GetNextDocument(docIn)
            i = i + 1
      Loop
      
      'store unique names in varUniqueAddressees
      'for this we call @Unique function and pass it the list of all names
      strMacro = {@Unique("} & StrImplode(strAddressees, {":"}) & {")}
      varUniqueAddressees = Evaluate(strMacro)
      
      'create a new document for all addressees
      Forall a In varUniqueAddressees
            Set docOut = db.CreateDocument
            With docOut
                  .SendTo = a
                  .Subject = "Your fixed subject"
                  Set rtBody = .CreateRichTextItem("Body")
            End With
            Call rtBody.AppendText(BODY_TEXT)
            Call rtBody.AddNewLine(1)
            '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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

  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…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now