372
MrNetman
NetWolf

Lotus Notes Task von Access heraus erzeugen

Mitglied: RDiller
13.03.2009
11:53:23 Uhr
2844 Aufrufe
1 Antwort
Noch nicht bewertet
Nach langem herumprobieren habe ich folgenden Code geschrieben um aus Access Lotus Notes Tasks, auch mit Attachments, zu erstellen.

01.
Private Sub 'Aufrufprozedur um den Task zu erstellen 
02.
	Dim UID as String 'UniversalID of TaskDocument 
03.
	UID = CreateNotesTask("Subject-Text", "Body-Text" , "01.01.2010 12:00:00", "C:\test.doc") 'die UID Speichere ich ab um danach wieder direkt auf den Task zugreifen zu können 
04.
          
05.
End sub 
06.
 
07.
 
08.
Public Function CreateNotesTask(Subject As String, Body As String, Task_Date As Date, Attachment_NO As String, Optional Attachment As String) 
09.
    Dim MailDbName             As String 
10.
    Dim ServerName             As String 
11.
    Dim TaskDoc                As Object 
12.
    Dim WorkSpace              As Object 
13.
    Dim objFso                 As New FileSystemObject 
14.
     
15.
	'Definition for the Server and Mail Database 
16.
    ServerName = "mail01/ffm01/aps" 
17.
    MailDbName = "mail01\5010.nsf" 
18.
 
19.
	'Initialize 
20.
    Set session = CreateObject("Notes.Notessession") 
21.
    Set Maildb = session.GetDatabase(ServerName, MailDbName) 
22.
     
23.
	'Create document 
24.
	Set TaskDoc = Maildb.CreateDocument 
25.
	'Define type of document to create 
26.
    TaskDoc.Form = "Task" 
27.
    'TaskDoc.CHAIR = <responsible Person or group> 
28.
    TaskDoc.DUESTATE = 2 ' 1 = Started, 2 = Not started, 8 = canceled, 9 = done 
29.
	 
30.
	'Set all Datevalues, so that the task will only be shown at the Task_Date 
31.
	TaskDoc.startDate = CStr(FormatDateTime(Task_Date, vbShortDate)) 
32.
    TaskDoc.StartDateTime = CStr(FormatDateTime(Task_Date, vbShortDate)) 
33.
    TaskDoc.DueDateTime = CStr(FormatDateTime(Task_Date, vbShortDate)) 
34.
    TaskDoc.DueDate = CStr(FormatDateTime(Task_Date, vbShortDate)) 
35.
    TaskDoc.enddate = CStr(FormatDateTime(Task_Date, vbShortDate)) 
36.
    TaskDoc.EndDateTime = CStr(FormatDateTime(Task_Date, vbShortDate)) 
37.
    TaskDoc.CALENDARDATETIME = CStr(FormatDateTime(Task_Date, vbShortDate)) 
38.
 
39.
	'Optional a Category	 
40.
    TaskDoc.Categories = "What you want" 
41.
 
42.
    'Optional to set a priority 
43.
    TaskDoc.Priority = 2  
44.
	'Set the Body Text 
45.
    Body = "Body Text" 
46.
	'If there is a path to an attachment 
47.
    If Attachment > "" Then 
48.
		'Check if the Path is correct 
49.
        FileExists = objFso.FileExists(Attachment) 
50.
        If Not FileExists Then 
51.
            MsgBox "Path to Attachment: " & Attachment & " is not valid!" 
52.
			Set TaskDoc = Nothing 
53.
			Set WorkSpace = Nothing 
54.
			exit function 
55.
        End If 
56.
        Set AttachME = TaskDoc.CreateRichTextItem("Attachment") 
57.
        Set EmbedObj = AttachME.EmbedObject(1454, "", Attachment, "Attachment") 
58.
    End If 
59.
	'Set Body-Text 
60.
    TaskDoc.Body = Body 
61.
	'Set Subject Text 
62.
    TaskDoc.Subject = Subject 
63.
	'Save the Document 
64.
    Call TaskDoc.ComputeWithForm(False, False) 
65.
    Call TaskDoc.Save(True, False, True) 
66.
    'Return of the  UniversalID 
67.
	SendNotesTask = TaskDoc.UniversalID 
68.
	Close everything 
69.
    Set TaskDoc = Nothing 
70.
    Set WorkSpace = Nothing 
71.
End Function

Diskussionsverlauf (1 Antwort)
Mitglied: Dani
Dani schreibt am 14.03.2009 um 19:15:45 Uhr
Hi,
ich finde es immer schön, wenn auch entsprechende Code mit ausreichend Kommentar versehen wird. du musst daran denken, dass andere User / Besucher nicht so "denken" wie du.
Bitte noch nachtragen...


Grüße,
Dani
mehr ...Ähnliche Beiträge