How to create a note with Attributes"ReminderTime"

132 views Asked by At

I want to create a note with reminder, this is my code:

'Create a note locally.
Dim myNote As New Note()

myNote.Title = "Sample note with Reminder set"
myNote.Content = "Hello, world - this note has a Reminder on it."
myNote.Attributes.ReminderTime = DateTime.Now.ToEdamTimestamp()

'Create the note in the service, in the user's personal, default notebook.
Dim store As ENNoteStoreClient =ENSessionAdvanced.SharedSession.PrimaryNoteStore
Dim resultNote As Note = store.CreateNote(myNote)

but it didn't work. The error code:

myNote.Attributes.ReminderTime = DateTime.Now.ToEdamTimestamp()

Full details:

未处理System.NullReferenceException HResult=-2147467261 Message=未将对象引用设置到对象的实例。

1

There are 1 answers

3
Phil Seeman On BEST ANSWER

A note's attributes are a NoteAttributesobject, so you have to create the object first:

'Create a note locally.
Dim myNote As New Note()

myNote.Title = "Sample note with Reminder set"
myNote.Content = "Hello, world - this note has a Reminder on it."

'Create the note's attributes.
Dim myNoteAttributes As New NoteAttributes

myNoteAttributes.ReminderTime = DateTime.Now.ToEdamTimestamp()
myNote.Attributes = myNoteAttributes    

'Create the note in the service, in the user's personal, default notebook.
Dim store As ENNoteStoreClient =ENSessionAdvanced.SharedSession.PrimaryNoteStore
Dim resultNote As Note = store.CreateNote(myNote)