Hi community!I am in desparate need for help. I have a VB routine that is supposed to send out group tasks with active alarm - but it does not work: the alarm does not go off.
Being a notes newbie I would much appreciate if someone could take a quick look through my lines of code.
Any feedback highly appreciated.
Thanks,
Kristof
Function WriteNotesTask(sEmpfaenger As String, sVerantwortlich As String, _
sBetreff As String, sBeschreibung As String, _
iPrio As Integer, dtFaellig As Date, iVorlauftage As Integer, _
Optional sKategorie, Optional sAbsender, Optional sVeranlasser) As Integer
'gibt bei Erfolg 0 zurück, sonst Fehlercode
On Error GoTo WriteNotesTask_err
Dim varEmpfaenger As Variant
Dim SendItem As Object
Dim body As Object
Dim i As Integer
Dim objNotes As lotus.NotesSession
Dim objNotesDB As lotus.NotesDatabase
Dim objNotesMailDoc As lotus.NotesDocument
Dim timeFaellig As Variant
Dim timeJetzt As Variant
Set objNotes = GetObject(“”, “Notes.Notessession”)
Set objNotesDB = objNotes.GetDatabase(“”, “”)
timeJetzt = (Now())
timeFaellig = Format(dtFaellig, “DD.MM.YYYY HH:MM:SS”)
Call objNotesDB.OPENMAIL
Set objNotesMailDoc = objNotesDB.CreateDocument
If IsMissing(sAbsender) Then sAbsender = objNotes.UserName: Debug.Print "Absender(default): " & sAbsender
If IsMissing(sVeranlasser) Then sVeranlasser = objNotes.UserName: Debug.Print "Veranlasser(default): " & sVeranlasser
With objNotesMailDoc
.form = "Task"
.Save True, False
'Mailempfänger
Set SendItem = .APPENDITEMVALUE("SendTo", "")
varEmpfaenger = Split(sEmpfaenger, ",")
For i = 0 To UBound(varEmpfaenger)
SendItem.AppendToTextList varEmpfaenger(i)
Next
.sendto = varEmpfaenger
.Subject = sBetreff
'Create and set the Body content
Set body = .CREATERICHTEXTITEM("Body")
body.APPENDTEXT (sBeschreibung)
body.AddNewLine (1)
'Example to create an attachment (optional)
'Call Body.ADDNEWLINE(2)
'Call Body.EMBEDOBJECT(1454, "", "C:\filename", "Attachment")
.ReplaceItemValue "$AltPrincipal", sAbsender 'CN=P3 Kling/...
.ReplaceItemValue "$CSFlags", "w"
.ReplaceItemValue "$CSVersion", "2"
.ReplaceItemValue "$ExpandGroups", "3"
.ReplaceItemValue "$NoPurge", timeFaellig
.ReplaceItemValue "$PublicAccess", "1"
.ReplaceItemValue "$SMTPKeepNotesItems", "1"
.ReplaceItemValue "$UpdatedBy", sAbsender
.ReplaceItemValue "_ViewIcon", 168
.ReplaceItemValue "AltChair", sVeranlasser
.ReplaceItemValue "AppendStartTime", Now()
.ReplaceItemValue "AppointmentType", "2"
.ReplaceItemValue "AssignedTo", sVerantwortlich
.ReplaceItemValue "AssignState", 2
If IsMissing(sKategorie) Then
.ReplaceItemValue "Categories", "P" 'Kategorie: Projekte
Else
.ReplaceItemValue "Categories", CStr(sKategorie)
End If
.ReplaceItemValue "Chair", sVeranlasser
.ReplaceItemValue "DefaultMailSaveOptions", "1"
.ReplaceItemValue "DeliveryPriority", "N"
.ReplaceItemValue "DeliveryReport", "B"
.ReplaceItemValue "DueDate", dtFaellig
.ReplaceItemValue "DueDateTime", dtFaellig
.ReplaceItemValue "DueState", "1"
.ReplaceItemValue "From", sAbsender
.ReplaceItemValue "Importance", CStr(iPrio) '1=hoch
.ReplaceItemValue "MailOptions", "0"
.ReplaceItemValue "OrgTable", "TO"
.ReplaceItemValue "PostedDate", Now()
.ReplaceItemValue "Principal", sAbsender
.ReplaceItemValue "Recipients", sEmpfaenger
.ReplaceItemValue "Repeats", ""
.ReplaceItemValue "ReturnReceipt", "1"
.ReplaceItemValue "SaveOptions", ""
.ReplaceItemValue "SequenceNum", "1"
.ReplaceItemValue "SMTPKeepNotesItems", "1"
.ReplaceItemValue "StartDate", Now()
.ReplaceItemValue "StartDateTime", Now()
.ReplaceItemValue "StartTime", Now()
.ReplaceItemValue "StorageRequiredNames", "1"
.ReplaceItemValue "TaskType", "2" 'Gruppen-Aufgabe
.ReplaceItemValue "tmpDspState", "0"
.ReplaceItemValue "tmpNoActionBar", ""
.ReplaceItemValue "tmpOwnerHW", "1"
.ReplaceItemValue "tmpReschedRepeatDatesList", ""
.ReplaceItemValue "UpdateSeq", 1
.ReplaceItemValue "WebDateTimeInit", "1"
.ReplaceItemValue "$Alarm", 1
.ReplaceItemValue "Alarms", "1"
.ReplaceItemValue "EndDate", dtFaellig
.ReplaceItemValue "EndDateTime", dtFaellig
.ReplaceItemValue "EndTime", dtFaellig
.ReplaceItemValue "$AlarmDescription", "AlarmDesc.: " & sBetreff
.ReplaceItemValue "$AlarmMemoOptions", "2"
.ReplaceItemValue "$AlarmOffset", (iVorlauftage * (-1440))
.ReplaceItemValue "$AlarmSendTo", sVerantwortlich
.ReplaceItemValue "$AlarmUnit", "D"
'ApptUNID=UNID??
.ReplaceItemValue "PostedDate", Now() 'Gets the mail to appear in the sent items folder
'Send the document
.Save True, False
.Send False
.RemoveItem ("DeliveredDate")
.Save True, False
End With
gstrUserName = objNotes.CommonUserName
'Clean Up
Set body = Nothing
Set objNotesMailDoc = Nothing
Set objNotesDB = Nothing
objNotes.Close
Set objNotes = Nothing
WriteNotesTask = 0
Exit Function