Update - Notes 8: Show Images Whitelist
Finn L. Knudsen 29 January 2009 19:30:02
The description is updated. I will soon upgrade to 8.5 and upload a new template.Notes 8: Show Images Whitelist
- Comments [0]
I do Code - A Weblog by Finn Ladegaard Knudsen. About Code and things related to Code | ||
Update - Notes 8: Show Images WhitelistFinn L. Knudsen 29 January 2009 19:30:02The description is updated. I will soon upgrade to 8.5 and upload a new template.Notes 8: Show Images Whitelist
NotesMimeEntity: Attach a file to MIMEFinn L. Knudsen 1 December 2008 21:13:15Here is the simple way to attach (and base64 encode) a file to MIME.Function MimeAttachFileAsBase64(mime As NotesMimeEntity, sFolderPath As String, sFileName As String) As Boolean On Error Goto ERRHANDLER Dim sess As New NotesSession Dim nsFile As NotesStream Dim mimeChild As NotesMimeEntity Dim mimeheader As NotesMimeHeader Dim sContentType As String MimeAttachFile = False Set nsFile = sess.CreateStream() If Not nsFile.Open(sFolderPath & sFileName, "Binary") Then Print "MimeAttachFileAsBase64 Error: Failed to open file: " & sFolderPath & sFileName Err = 0 Exit Function End If Set mimeChild = mime.CreateChildEntity() sContentType = |application/octet-stream| ' application/octet-stream is a default value Call mimeChild.SetContentFromBytes( nsFile, sContentType & |; name="| & sFileName & |"|, ENC_NONE) ' base64 encode the file Call mimeChild.EncodeContent( ENC_BASE64) ' Content-Disposition header Set mimeheader = mimeChild.createHeader("Content-Disposition") Call mimeheader.SetHeaderVal(|attachment; filename="| & sFileName & |"|) ' close stream and cleanup Call nsFile.Close() Set nsFile = Nothing MimeAttachFile = True Exit Function ERRHANDLER: Print "MimeAttachFileAsBase64 Error: " & Format$(Err) & " " & Error & " # Line: " & Format$(Erl) Err = 0 Exit Function End Function
Notes 8: Show Images WhitelistFinn L. Knudsen 26 November 2008 08:00:00Now 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
If The Matrix ran on WindowsFinn Ladegaard Knudsen 20 November 2008 21:46:11The Windows version of The Matrixhttp://www.youtube.com/watch?v=yX8yrOAjfKM Source: http://www.leadershipbynumbers.com/ms.nsf/d6plinks/BMAA-7LKH4Y
Undocumented: notesUIDocument.Refresh( [ IncludeRichTextItems ], [ RefreshEmbeddedObjects ] )Finn L. Knudsen 16 November 2008 18:03:37In Notes 7 we have the optional RefreshEmbeddedObjects refresh embedded views and editors on the form.And Notes 8 gives us an extra feature SkipAddressLookups notesUIDocument.Refresh( [ IncludeRichTextItems ], [ RefreshEmbeddedObjects ], [ SkipAddressLookups ] ) Source: http://www.vitor-pereira.com/sd/blog.nsf/d6plinks/7L6HUJ
Undocumented: @Command( [OpenCalendar]; username; ...Finn L. Knudsen 16 November 2008 11:26:55From Steve Castledine's blog:"Here are the undocumented commands to achieve this (hopefully they are self explanatory): @Command( [OpenCalendar]; username; [UseMailFrameset]) @Command( [OpenCalendar]; username; [UseToDoFrameset]) @Command( [OpenCalendar]; username; [UseContactsFrameset]) (this was only added at 8.0 for the delegated contacts work) " Source: http://www.stevecastledine.com/sc.nsf/dx/using-formula-to-open-a-designated-users-calendar-to-do-or-contacts
Passing Arguments by Value and by ReferenceFinn L. Knudsen 15 November 2008 10:00:00When you are calling an external function:C-API function or OLE objects Be aware of how the value is passed. Example with wrong passing of value: Dim vWinHTTP As Variant Set vWinHTTP = CreateObject("WinHTTP.WinHTTPRequest.5.1") Dim sSoapEnvelope As String sSoapEnvelope = |<?xml version="1.0" encoding="utf-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> <SOAP-ENV:Body> <m:SAYHELLO xmlns:m="urn:DefaultNamespace" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <NAME xsi:type="xsd:string">Finn Knudsen</NAME> </m:SAYHELLO> </SOAP-ENV:Body> </SOAP-ENV:Envelope>| Call vWinHTTP.Open( "POST", "http://idocode.net/ws/helloworld", False ) Call vWinHTTP.Send( sSoapEnvelope ) ' Don't do like this. Passing by reference . The last line should be: Call vWinHTTP.Send( (sSoapEnvelope) ) ' Passing by value In the example you don't get an error when you call .Send with the value passed as reference, but the reply from the server won't be what you expected. From MSDN documentation of WinHTTPRequest: Sub Send( _ [ ByVal varBody As VARIANT ] _ ) See more on: Lotus Domino Designer Help: "Passing arguments by reference and by value " http://msdn.microsoft.com/en-us/library/ddck1z30.aspx http://www.ls2capi.com/web/ls2capi/ls2capihome.nsf/Content/SC_DATA_TYPES?OpenDocument&ExpandOutline=1.2
Wellcome to my BlogFinn L. Knudsen 14 November 2008 20:57:49Here I will blog about code I am using and it will be my public code archive.I am standing on the shoulders of giants. My work is inspired of what others have done. And I will give credit to the original work when I am aware of the source. If you feel that I have violated your property or should show you more respect and give you proper credit, please let me know. You will find my contact information on my company’s homepage. www.alces.net
’Added to File’ the missing NotesDocument PropertyFinn L. Knudsen 14 November 2008 14:03:47Copy of the code I posted on bleedyellow.com 2008.04.04This function returns the date/time a NotesDocument has been added to the Notes database. And if the document is added by the replicator it is different from 'Created'. I have used it to find documents that once where delete but reappeared after a replication with an old replica of the database. 'This LotusScript function uses the Notes API to access the 'Added to File' property for a NotesDocument. ' Declarations Type TIMEDATESTRUCTE Innards(1) As Long End Type Declare Sub W32_NSFNoteGetInfo Lib "nnotes" Alias "NSFNoteGetInfo" (_ Byval note_handle As Long, _ Byval note_member As Integer, _ value_ptr As Any ) Declare Function W32_ConvertTIMEDATEToText Lib "nnotes.dll" Alias "ConvertTIMEDATEToText" (_ Byval nullFormat As Long, _ Byval textformat As Long, _ td As Any, _ Byval Buff As String, _ Byval maxlen As Integer, _ textLength As Integer) As Integer %REM * Note structure member IDs for NSFNoteGet&SetInfo. */ #define _NOTE_DB 0 /* IDs for NSFNoteGet&SetInfo */ #define _NOTE_ID 1 /* (When adding new values, see the */ #define _NOTE_OID 2 /* table in NTINFO.C */ #define _NOTE_CLASS 3 #define _NOTE_MODIFIED 4 #define _NOTE_PRIVILEGES 5 /* For pre-V3 compatibility. Should use $Readers item */ #define _NOTE_FLAGS 7 #define _NOTE_ACCESSED 8 #define _NOTE_PARENT_NOTEID 10 /* For response hierarchy */ #define _NOTE_RESPONSE_COUNT 11 /* For response hierarchy */ #define _NOTE_RESPONSES 12 /* For response hierarchy */ #define _NOTE_ADDED_TO_FILE 13 /* For AddedToFile time */ #define _NOTE_OBJSTORE_DB 14 /* DBHANDLE of object store used by linked items */ %END REM ' Functions Function NotesDocumentAddedToFile( ndoc As NotesDocument) As Variant Dim hNote As Long Dim tds As TIMEDATESTRUCTE Dim sDateTime As String*256 Dim iDate As Integer Dim vDateTime As Variant hNote = ndoc.Handle Call W32_NSFNoteGetInfo( hNote, 13, tds ) Call W32_ConvertTIMEDATEToText (0,0,tds, sDateTime, 256, iDate%) ' convert to variant DateTime vDateTime = Cdat( sDateTime) NotesDocumentAddedToFile = vDateTime End Function
Hello WorldFinn L. Knudsen 13 November 2008 09:13:28Well this is about code so the first entry must be "Hello World" .I did my first Hello World program in Basic on a ZX80. And I have since then coded that program in Assembler, Pascal, C, C++, VB, SmallTalk, Java, HTML, XSLT, JavaScript, C# and more. It is a test to prove that I have a valid enviroment to build and run a program. And this is my test of this blog. Are you still there!! Wellcome to my blog.
| Recent EntriesRecent Comments | |