Creating the "Mark unsigned mail with attachment" agent

The "Mark unsigned mail with attachment" agent automatically checks for unsigned mail carrying an attachment.

First published on IBM developerWorks.

The "Mark unsigned mail with attachment" agent automatically checks for unsigned mail carrying an attachment. Because more and more mail messages are sent using an unknown or even a fake user ID, this agent can add one more level of security to help your organization prevent the spreading of worms and viruses.

In your Inbox, mail messages that have one or more attachments but don't have a digital signature will look like the fourth mail message (from the top) in the following screen. (Notice the bomb icon instead of the paper clip.)

Figure 1. Mail message with attachment marked as unsigned
Figure 1

Note: The bomb icon in the Subject column does not necessarily indicate a virus; it only indicates that the mail message contains an attachment, but has no digital signature. The other messages shown in the previous screen may or may not be signed. The "Mark unsigned mail with attachment" agent runs only on those messages that contain attachments. You can modify this agent to run on all mail messages if you prefer.

Creating the "Mark unsigned mail with attachment" agent

  1. Open a server replica or copy of a mail database.
  2. In Notes 5, choose Create - Agent. In Notes 6 or later, choose Create - Design - Agent.
  3. In the Agent Properties box, enter a name for the agent. We use "Mark unsigned mail with attachment."
  4. In Notes 5, select the Shared Agent option. In Notes 6 or later, select the Shared option.
  5. In Notes 5, in the "When should this agent run" field, select Before New Mail Arrives. In Notes 6 or later, select the same option from the Runtime drop-down list.
  6. In the Run drop-down list of the programmer's pane, select LotusScript.
  7. In the Objects pane, click Initialize, then delete the default lines: Sub Initialize ... End Sub.
  8. Add the following code to the agent:
    Sub Initialize
            Dim icon As Integer
            icon = 91
            Dim session As New NotesSession
            Dim doc As NotesDocument
            Dim it  As NotesItem
            Set doc = session.documentcontext
            If doc.HasEmbedded Then
                    If  Not doc.IsSigned Then
                            Set it = doc.GetFirstItem
    ("$ContentIcon")
                            Call doc.ReplaceItemValue
    ("$ContentIcon", icon)
                            Call doc.Save(True, False)
                    End If   
            End If
    End Sub
    
  9. Save and close the agent.

If you have the Mark incoming mail agent...

If you have already installed an agent for distinguishing incoming mail by To: and cc: (see the tip, Mark incoming mail for more information), add the following code rather than the code shown in the previous section:

Sub Initialize
        Dim icon As Integer
        icon = 91
        Dim session As New NotesSession
        Dim doc As NotesDocument
        Dim it  As NotesItem
        Set doc = session.documentcontext
        If doc.HasEmbedded Then
                If  Not doc.IsSigned Then
                        Set it = doc.GetFirstItem
("$ContentIcon")
                        Call doc.ReplaceItemValue
("$ContentIcon", icon)
                        Call doc.Save(True, False)
                End If   
        End If
        Const macro$ = "TO1:=3;TO2:=4;
CC1:=22;CC2:=21;BCC:=163;
DISTR:=70;" +_
        "userName:=@ProperCase
(@DbTitle);tmpvar:=@If(_ViewIcon!=""""&" +_
        "_ViewIcon!=0;0;@IsDocTruncated;0;
@ProperCase(@Name
        ([CN];SendTo))=userName;" +_
        "@If(@Elements(SendTo)=1;TO1;TO2);
@ProperCase(@Name
        ([CN];CopyTo))=userName;" +_
        "@If(@Elements(CopyTo)=1;CC1;CC2);
BlindCopyTo!="""";BCC;SendTo!
        ="""";DISTR;0);" +_
        "@Return(tmpvar)"
        Dim result As Variant
        result = Evaluate( macro$, doc)
        If Not result(0) = 0 Then
                Set it = doc.GetFirstItem("_ViewIcon")
                Call doc.ReplaceItemValue
("_ViewIcon", result(0))
                Call doc.Save(True, False)
        End If 
End Sub

Customization

If you prefer another icon to the bomb, use a number other than 91 in the second line of the preceding code:

icon = 91

For example, if you use 92 instead, you will get a stop sign icon as shown in figure 2. See the topic, "Displaying an icon in a column" in the Domino Designer help for a list of column icons that you can use.

Figure 2. Stop sign icon
Figure 2

For more information about Notes mail, see the following:

Do you have comments on this tip? Let us know.

This was last published in September 2004

Dig Deeper on Development Security for Lotus Notes Domino

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchExchange

SearchContentManagement

Close