I do Code - A Weblog by Finn Ladegaard Knudsen. About Code and things related to Code

Notes 8: Show Images Whitelist

Finn L. Knudsen  26 November 2008 08:00:00
Now I don’t have to click the ‘Show Images’ on my daily Dilbert email.
This is an extension of the Notes 8 security function to block linked images. It stores a Whitelist in a profile-document.

(you can download the code here)
ShowImagesWhitelist.zip (english version 8)

Contains:
A new form "ShowImagesWhitelist"
A replacment for the subform "(FollowUpMemoSubform)"


The main part of the code is an Action and PostOpen on a subform.

Action code
 (to add the Sender to the  Whitelist)
Sub AddToWhitelist()

        Dim ws As New NotesUIWorkspace
        Dim s As New NotesSession
        Dim ndProfile As NotesDocument
        Dim ni As NotesItem
        Dim sWhiteListAddr As String
       
        sWhiteListAddr = Inputbox$( "Whitelist Senders email address." & Chr(10) & _
        "Use * to Whitelist all from one domain. e.g: *@acme.com" & Chr(10) & Chr(10) & _
        "Add to Whitelist:" , "Always show images from Sender" , ws.CurrentDocument.Document.SMTPOriginator(0) )
        If sWhiteListAddr = "" Then Exit Sub
        Set ndProfile = s.CurrentDatabase.GetProfileDocument(PROFILEWHITELIST, s.UserName)
        If ndProfile.HasItem(FIELDWHITELIST) Then
                Set ni = ndProfile.GetFirstItem(FIELDWHITELIST)
                Call ni.AppendToTextList( sWhiteListAddr )
        Else
                Call ndProfile.AppendItemValue(FIELDWHITELIST, sWhiteListAddr )
        End If
        Call ndProfile.Save(True, True)
        If ws.CurrentDocument.Document.~$DelayedImagesOK(0) <> "0" _
        And ws.CurrentDocument.Document.~$DelayedImagesOK(0) <> "ok" _
        Then
                If ws.CurrentDocument.Document.HasItem("$DelayedImagesOK") Then
                        Call ws.CurrentDocument.Document.RemoveItem("$DelayedImagesOK")
                End If
                Call ws.CurrentDocument.Document.AppendItemValue("$DelayedImagesOK", "ok")
                Call ws.CurrentDocument.Refresh                                        
        End If
End Sub


PostOpen code

Sub Postopen(Source As Notesuidocument)

        If Not source.EditMode Then
                If Source.Document.HasItem("MIME_Version") Then
                        Dim sDelayedImagesOK As String
                        sDelayedImagesOK = Format$(Source.Document.~$DelayedImagesOK(0) )
                        If sDelayedImagesOK <> "0" _
                        And sDelayedImagesOK <> "ok" _
                        Then
                                Dim ndProfile As NotesDocument
                                Set ndProfile = Source.Document.ParentDatabase.GetProfileDocument(PROFILEWHITELIST, _
                                Source.Document.ParentDatabase.Parent.UserName)
                                If ndProfile.HasItem(FIELDWHITELIST) Then
                                        Dim vWhitelist As Variant
                                        Dim sOriginator As String
                                        Dim sOriginatorDomain As String
                                       
                                        sOriginator Format$(Source.Document.SMTPOriginator(0))
                                        If sOriginator <> "" Then
                                                sOriginatorDomain = "*@" & Right$(sOriginator, Len(sOriginator) - Instr(1, sOriginator, "@") )
                                                vWhitelist = ndProfile.GetItemValue(FIELDWHITELIST)
                                                If Instr(1,  Join(vWhitelist, ","), sOriginator, 1) > 0 _
                                                Or Instr(1,  Join(vWhitelist, ","), sOriginatorDomain, 1) > 0 _
                                                Then
                                                        Print "Show Images - Whitelist"
                                                        If Source.Document.HasItem("$DelayedImagesOK") Then
                                                                Call Source.Document.RemoveItem("$DelayedImagesOK")
                                                        End If
                                                        Call Source.Document.AppendItemValue("$DelayedImagesOK", "ok")
                                                        Call Source.Refresh                
                                                End If
                                        End If
                                End If
                        End If
                End If
        End If
End Sub

Comments

1Toni  17.3.10 15:24:02  Notes 8: Show Images Whitelist

great, simple and helpful. thank you

Technorati Profile Add to Technorati Favorites