I recently had the need to send a response email from an account that was set for "no_reply" address. I wanted the sender to get a response, but I didn't want responses to that response to come back to me. Here is the code that I ended up with. Works well for internet email. Enjoy and put this to good use!
%REM
Description: This agent will send a response to all email sent to an account
Set this agent to trigger before new mail arrives
%END REM
Option Public
Option Declare
Sub Initialize
' Sends a response email to all mail received
'
Dim ses As New NotesSession
Dim currentDoc As NotesDocument
Dim db As NotesDatabase
Dim maildoc As NotesDocument
Dim msg1, msg2, msg3, msg4 As Variant
Dim rtitem As NotesRichTextItem
Dim Principle As String
Set db = ses.currentDataBase
Set maildoc = New NotesDocument(db)
Set currentDoc = ses.documentContext
maildoc.Form = "Memo"
Principle = "no_reply@some_domain.com"
maildoc.Principal = |"Do Not Respond" <| + Principle + |@some_domain.com>|
maildoc.From = Principle
maildoc.AltFrom = Principle
maildoc.SendFrom = Principle
maildoc.INetFrom = Principle
maildoc.tmpDisplaySentBy = Principle
maildoc.tmpDisplayFrom_Preview = Principle
maildoc.DisplaySent = Principle
maildoc.SendTo = currentDoc.GetItemValue("From")(0)
maildoc.Subject = "New Contact Information"
msg1 = "The owner of this process has changed. Please contact:" & Chr(13)
msg2 = "person1@some_domain.com or person2@some_domain.com"
msg3 = " for any future correspondence." & Chr(13)& Chr(13)
msg4 = "Thank You" & Chr(13) & Chr(13)
Set rtitem = maildoc.CreateRichTextItem( "Body" )
Call rtitem.AppendText(msg1 & msg2 & msg3 & msg4)
Call maildoc.send(False)
End Sub
If it's tech related...I'll post it here. Lotus Notes/Domino, AS400 or iSeries, PC's, PDA's, iPods, Android -- Whatever.
Tuesday, September 11, 2012
Wednesday, May 30, 2012
Clear Lotus Notes "Recent Contacts" List
Do you have Lotus Notes 8.x and don't want to have contacts in your user's Recent Contacts list? You can turn this off but maybe you just want to clear it to see if there is an issue. Instead of trying to walk your users through deleting the information, just send them a button that says "Click Here" with the below Lotus Script code:
%REM
Agent Remove Recent Contacts
Description: Clear recent contacts with just a click
%END REM
Option Declare
Sub Click(Source As Button)
Dim ses As New NotesSession
Dim v As NotesView
Dim col As NotesViewEntryCollection
Dim entry As NotesViewEntry
Dim doc As NotesDocument
Dim x As Integer
x = 0
' For The Current User in The Current Session, Get All The NABs
Forall books In ses.addressbooks
'Check If The Current NAB is Private or Public
'If The NAB Is Private, Then It Should Be Your Personal NAB
If books.isprivateaddressbook Then
'Verify if The NAB is Open, If Not, Open it
If Not(Books.isopen) Then
Call Books.open("",books.filename)
End If
Set v = books.getview("RecentCollaborators")
Set col = v.AllEntries
Set entry = col.GetFirstEntry()
While Not(entry Is Nothing)
Set doc = entry.Document
doc.Remove(True)
x = x + 1
Set entry = col.GetNextEntry(entry)
Wend
Print "Removed " & x & " Recent contacts"
End If
End Forall
End Sub
Labels:
Domino,
Email,
Lotus Script,
View
Enable an Agent then Sign It With The Server ID
Do you need to turn an Agent Off or On -- but keep it signed by your server? This script will do the trick. It is especially useful if you are sending email from the agent but don't want it coming from anyone other than your server. Name your agent in the code, add this to a button in your application and you'll be all set!
Option Public
Option Declare
'Declarations.
Dim debug As Integer
Dim sdoc As NotesDocument
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim agent As NotesAgent
Dim adminp As NotesAdministrationProcess
Dim agentFound As Integer
Dim nam As NotesName
Dim noteid As String
Set db = session.CurrentDatabase
agentFound = False
'Get the agent.
Forall a In db.Agents
If ( a.Name = "Some Agent Name" ) Then
Set agent = a
agentFound = True
Print "Agent " + agent.Name + " found."
Exit Forall
End If
End Forall
'Enable the agent.
If agentFound Then
agent.IsEnabled = True
Call agent.Save
Print "Agent " +agent.Name + " enabled."
End If
'Issue AdminP request to sign database with server's ID.
Set nam = session.CreateName( db.Server )
Set adminp = session.CreateAdministrationProcess( nam.Abbreviated )
noteid$ = adminp.SignDatabaseWithServerID( nam.Abbreviated, db.FilePath )
Print "Issued AdminP request to sign database with server's ID."
End Sub
Labels:
Domino,
Email,
Lotus Script
Tuesday, May 29, 2012
Coming soon.....a review of my new Samsung Galaxy Note phone!
I finally broke down and updated my phone from the Samsung Galaxy S (Captivate) to the very large and very useful Samsung Galaxy Note. I've purchased a case and a cover for it. One of my most favorite phones to date.
Labels:
Android
Thursday, March 29, 2012
Lotus Script File Exists Function
Have you ever needed to verify that a file was really there before you opened it in LotusScript? Nothing is more fun than to try and access a database that's not there. So what do you do? How about checking to see if it exists first?
Now I didn't write this function, so I'll not take 100% credit for it. But I did make some changes so that it returns either True or False when you use it.
If your LotusScript says Print "File Names.nsf is present is " & FileExists("names.nsf") you should get:
Files Names.nsf is present is True since you must have this file in order to run your client or server.
Here is the code:
Function FileExists(filenm As String) As Boolean
' Tests if file exists, returns True for yes, False for no
On Error GoTo FErrorHandler 'Bail on an error
'Test file
If (Dir$(filenm)="") Then
'No file exists
FileExists = False
Else
'File exists
FileExists = True
End If
Exit Function
FErrorHandler:
'We had an error, so we assume there was no file found
FileExists = False
Exit Function
End Function
Now I didn't write this function, so I'll not take 100% credit for it. But I did make some changes so that it returns either True or False when you use it.
If your LotusScript says Print "File Names.nsf is present is " & FileExists("names.nsf") you should get:
Files Names.nsf is present is True since you must have this file in order to run your client or server.
Here is the code:
Function FileExists(filenm As String) As Boolean
' Tests if file exists, returns True for yes, False for no
On Error GoTo FErrorHandler 'Bail on an error
'Test file
If (Dir$(filenm)="") Then
'No file exists
FileExists = False
Else
'File exists
FileExists = True
End If
Exit Function
FErrorHandler:
'We had an error, so we assume there was no file found
FileExists = False
Exit Function
End Function
Labels:
Domino,
Lotus Script
Tuesday, March 13, 2012
Wrong Image Count On Android Gallery - Part 2
As I mentioned in my first post on this issue, there seems to be multiple ways to cleanup you Android Gallery image counts. Here's the last one I tried (and came up with).
If you have folder called "Pictures" that shows 100 images, but really has on 10 you can do the following to correct. 1) Using a file system tool such as Astro, rename your folder from Pictures to Pic. This should make your SD cards be rescanned. 2) Open the Gallery app and you should now see a Pictures folder and a Pic folder. Pictures should still show 100 images and Pic should show 10. 3) Long press on the Pictures folder and select delete to remove it. 4) Exit Gallery. 5) Open Astro again and this time rename Pic back to Pictures. Open Gallery again and you should see the Pictures folder with the correct image count.
I'm not sure what the issue is with Gallery on Android 2.x, but this sure is an annoying problem. I know that I don't have this issue on my Acer A500 running Android 3.x. And most of the time I like to use QuickPic as a Gallery replacement.
Enjoy!
If you have folder called "Pictures" that shows 100 images, but really has on 10 you can do the following to correct. 1) Using a file system tool such as Astro, rename your folder from Pictures to Pic. This should make your SD cards be rescanned. 2) Open the Gallery app and you should now see a Pictures folder and a Pic folder. Pictures should still show 100 images and Pic should show 10. 3) Long press on the Pictures folder and select delete to remove it. 4) Exit Gallery. 5) Open Astro again and this time rename Pic back to Pictures. Open Gallery again and you should see the Pictures folder with the correct image count.
I'm not sure what the issue is with Gallery on Android 2.x, but this sure is an annoying problem. I know that I don't have this issue on my Acer A500 running Android 3.x. And most of the time I like to use QuickPic as a Gallery replacement.
Enjoy!
Wednesday, February 8, 2012
Select a date and update your view
Well, it's 2012 and I realized that I've not made any entries for this year. So, here's my first tip of the year.
If you create a view that selects documents based on date using @Today or @Now, you will constantly be refreshing that view and eating up resources. Even more, if you have a large number of documents in the database you will be recalculating what is displayed and causing slow performance for your users. A better way is to update the view selection formula via Lotus Script to have a "static" selection formula -- even though you can prompt the user for input to change it. Below is a sample script to do this. As a side note, your users must have the attribute "Create shared folders/views" selected in order to update the view selection formula.
I promise to try and get additional posts done in a little more timely fashion -- even though this blog is only updated "every so often...". Have a great day!
%REM
Agent UpdateViewSelections
***********************************************
Written Feb 03, 2012
***********************************************
' This script will update a view selection formula with
' an actual date versus doing the same thing via the @Today
' function (which recalculates constantly).
' So you go from:
' SELECT (Form = "myForm") & (@Created > @Adjust(@Today;0;0;-60;0;0;0))
' To:
'SELECT (Form = "myForm") & (@Created > [06/26/2011])
' This should improve the performance of this view since
' your index is not constatnly being recalculated.
***********************************************
%END REM
Option Public
Option Declare
%Include "lsconst.lss"
Sub Initialize
On Error GoTo ErrorHandler
Dim ses As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim formula As String
Dim fmMonth As Variant
Dim fmYear As Variant
Dim fmDate As Variant
Dim getDate As Variant
Dim wrkDate As Variant
Dim workspace As New NotesUIWorkspace
Set db = ses.CurrentDatabase
Set view = db.GetView("SelectMonth")
getDate = workspace.Prompt(Prompt_OKCANCELEDIT,"Select Date For Review","Enter Date (use format MM/DD/YY)","")
If IsEmpty(getDate) Then Exit Sub 'We canceled or didn't enter anything
If CDat(getDate) < CDat("01/01/2005") Then GoTo ErrorHandler
wrkDate = CDat(getDate)
fmMonth = Month(wrkDate)
fmYear = Year(wrkDate)
formula = {SELECT Form = "myForm" & } &{ (@Month(ADATE) = } & fmMonth & {) & (@Year(ADATE) = } & fmYear & {) ;}
view.SelectionFormula = formula
Call workspace.viewrebuild 'Reset our view and exit
Exit Sub
ErrorHandler:
MessageBox "The information you entered is not valid", MB_OK, "Did you enter a valid date?"
Exit Sub
End Sub
If you create a view that selects documents based on date using @Today or @Now, you will constantly be refreshing that view and eating up resources. Even more, if you have a large number of documents in the database you will be recalculating what is displayed and causing slow performance for your users. A better way is to update the view selection formula via Lotus Script to have a "static" selection formula -- even though you can prompt the user for input to change it. Below is a sample script to do this. As a side note, your users must have the attribute "Create shared folders/views" selected in order to update the view selection formula.
I promise to try and get additional posts done in a little more timely fashion -- even though this blog is only updated "every so often...". Have a great day!
%REM
Agent UpdateViewSelections
***********************************************
Written Feb 03, 2012
***********************************************
' This script will update a view selection formula with
' an actual date versus doing the same thing via the @Today
' function (which recalculates constantly).
' So you go from:
' SELECT (Form = "myForm") & (@Created > @Adjust(@Today;0;0;-60;0;0;0))
' To:
'SELECT (Form = "myForm") & (@Created > [06/26/2011])
' This should improve the performance of this view since
' your index is not constatnly being recalculated.
***********************************************
%END REM
Option Public
Option Declare
%Include "lsconst.lss"
Sub Initialize
On Error GoTo ErrorHandler
Dim ses As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim formula As String
Dim fmMonth As Variant
Dim fmYear As Variant
Dim fmDate As Variant
Dim getDate As Variant
Dim wrkDate As Variant
Dim workspace As New NotesUIWorkspace
Set db = ses.CurrentDatabase
Set view = db.GetView("SelectMonth")
getDate = workspace.Prompt(Prompt_OKCANCELEDIT,"Select Date For Review","Enter Date (use format MM/DD/YY)","")
If IsEmpty(getDate) Then Exit Sub 'We canceled or didn't enter anything
If CDat(getDate) < CDat("01/01/2005") Then GoTo ErrorHandler
wrkDate = CDat(getDate)
fmMonth = Month(wrkDate)
fmYear = Year(wrkDate)
formula = {SELECT Form = "myForm" & } &{ (@Month(ADATE) = } & fmMonth & {) & (@Year(ADATE) = } & fmYear & {) ;}
view.SelectionFormula = formula
Call workspace.viewrebuild 'Reset our view and exit
Exit Sub
ErrorHandler:
MessageBox "The information you entered is not valid", MB_OK, "Did you enter a valid date?"
Exit Sub
End Sub
Labels:
Date,
Domino,
Lotus Script,
View
Subscribe to:
Posts (Atom)