LotusScript Agent - Move Mail to Folders

I posted this before but, there has been an update to this request since I intially posted it.

The update is that of our 190 Facilities, they are broken down into 3 Regions. The customers would like these Facility sorted by Regions.

Example:

  • Test User/12345/FAC/Org sends message

  • Message should populate Folder → Region1\12345

  • Test User/44444/FAC/Org sends message

  • Message should populate Folder → Region2\44444

  • Test User/99999/FAC/Org sends message

  • Message should populate Folder → Region3\99999

Any suggestions?

Thanks in advance.

MKV

======================================

Previous Post

I have an issue regarding the # of Rules for a Notes Client to run. I know there is a maximum of 100 that can be set for the Client but, I have a Mail-In database that receives messages from 190 of our facilities. My customer would like for all incoming messages to be filed automatically into their respective Facility Folders.

Example:

If Test User/12345/Facility sends a message to the Mail-In Database then, the message should automatically be filed in Folder 12345.

If Test User/99999/Facility sends a message to the Mail-In Database then, the message should automatically be filed in Folder 99999.

But, since I cannot use 190 Mail Rules for this Mail-In Database, Mail Rules is not an option.

I am a Domino Admin, not an App. Dev. so any suggestions would be helpful.

Thanks in advance.

Marcie

Subject: LotusScript Agent - Move Mail to Folders

Hey, Marcie! :wink:

I’m sure I’m missing some of the picture, but why not 1 mail-in rule? Everything goes into one mail-in database, and an agent in there will put the e-mails in the proper folder? You can create an agent set to “After new mail has arrived”. The agent can read the sender, and then decide what folder to put the document.

Does this make sense?

Good luck!

Steve in NYC

“Weeks of coding can save you hours of planning.”

Subject: RE: LotusScript Agent - Move Mail to Folders

Hi Steve,

Thanks for your response. Actually, this is a Mail-In Database that has 190 Facilities, in 3 Regions, sending Mail to it. What the customer would like is to have the 3 Folders (3 Regions) and then Facility Sub-Folders within each of the 3 Regions. Since I can’t create more than 100 Mail Rules, I am thinking that if I could get LotusScript to sort and folder the incoming messages by Facility#(Sub-Folder) within their Region(Folder).

Example:

Folders

Region1

  • 12345

  • 12346

  • 12347

    <and so on - there are 47 Facilities in this Region>

Region2

  • 22345

  • 22346

  • 22347

    <and so on - there are 84 Facilities in this Region>

Region3

  • 32345

  • 32346

  • 32347

    <and so on - there are 59 Facilities in this Region>

All Users are Certified as follows:

Test User/12345/FAC/Org

Test User/22345/FAC/Org

Test User/32345/FAC/Org

I hope this explains it a little better.

Thanks.

Marcie

Subject: RE: LotusScript Agent - Move Mail to Folders

Howdy!

Ok… it’s a bit more clear. =8P What would the subfolders be? I still think we’re missing something here… For example, if “Test User/22347/FAC/Org” sends something, which folder does it go to? Would it be “Region2\22347”?

If so, I whipped up a bit of (untested) Lotusscript below. You may need to play around a bit to get the “v_tmp” & “v_folder” variables correct. I’m assuming that the e-mail comes into the “$Inbox” folder. Use the debugger to try it out.

  • Agent run “After new mail arrives” or “After documents are created or modified”.

  • Target: “none”

  • Script would be something like this:

dim ns as new NotesSession

dim ndb as NotesDatabase

dim nv as NotesView

dim nd, nd_Next as NotesDocument

dim v_tmp as variant

dim v_folder as string

set ndb = ns.CurrentDatabase

set nv = ndb.GetView(“$Inbox”)

set nd_Next = nv.GetFirstDocument

Do Until nd_Next is nothing

set nd = nd_Next

set nd_Next = nv.GetNextDocument(nd_Next)

’ process “nd” to read the sender’s name, and decide on which folder…

v_tmp = evaluate({@Middle(“} & nd.From(0) & {”; “/”; “/”)}, nd)

v_folder = “Region” & left$(v_tmp(0), 1) & “\” & v_tmp(0)

call nd.PutInFolder(v_folder)

call nd.RemoveFromFolder(“$Inbox”)

Loop

Exit Sub

Have fun!

Steve in NYC

“Profanity is the one language all programmers know best.”

Subject: RE: LotusScript Agent - Move Mail to Folders

Thank you, Steve. I will test this and let you know. I appreciate your efforts.

Subject: RE: LotusScript Agent - Move Mail to Folders

Thanks Steve,

Your Post Quotes gave me the best chuckle I have had all day!

Shawn