This repository has been archived by the owner on Mar 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Filename.lss
85 lines (70 loc) · 1.99 KB
/
Filename.lss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
%REM
Library Filename
Created May 5, 2015 by Bernd Berger
Description: get a nice filename when exporting mails...
%END REM
Option Public
Option Declare
Function Filename(doc As NotesDocument, path As String) As String
Dim length As Integer
Dim NDate As NotesDateTime
Dim strYear As String
Dim strMonth As String
Dim strDay As String
Dim strNDate As String
Dim strSender As String
length = 240 - Len(path)
'set date
Set NDate = getTime(doc)
'Jahr
If Year(NDate.Dateonly) < 1000 Then
strYear = "0" & CStr(Year(NDate.Dateonly))
Else
strYear = CStr(Year(NDate.Dateonly))
End If
'Monat
If Month(NDate.Dateonly) < 10 Then
strMonth = "0" & CStr(Month(NDate.Dateonly))
Else
strMonth = CStr(Month(NDate.Dateonly))
End If
'Tag
If Day(NDate.Dateonly) < 10 Then
strDay = "0" & CStr(Day(NDate.Dateonly))
Else
strDay = CStr(Day(NDate.Dateonly))
End If
strNDate = strYear & strMonth & strDay
strSender = getSender(doc)
If Not doc.Getitemvalue("Subject")(0) = "" Then
Filename = Left$(strNDate & " - " & strSender & " - " & doc.Getitemvalue("Subject")(0), length)
Else
Filename = Left$(strNDate & " - " & strSender & " - No Subject", length)
End If
End Function
Function getSender(mail As NotesDocument) As String
Dim s As New NotesSession
Dim n As New NotesName(mail.From(0))
Dim m As New NotesName(mail.SendTo(0))
Dim doc As NotesDocument
Set doc = s.Currentdatabase.Getprofiledocument("CalendarProfile")
If doc.Getitemvalue("Owner")(0) = n.Canonical Then
getSender = Left(m.Common & " (from " & n.Common & ")", 50)
Else
getSender = Left(n.Common, 25)
End If
End Function
Function getTime(mail As NotesDocument) As NotesDateTime
Dim item As NotesItem
Set item = mail.GetFirstItem("DeliveredDate" )
If (item Is Nothing) Then
Set item = mail.GetFirstItem("OriginalModTime")
If (item Is Nothing) Then
Set getTime = New NotesDateTime(mail.Created)
Else
Set getTime = item.DateTimeValue
End If
Else
Set getTime = item.DateTimeValue
End If
End Function