Outlook 2003: Prevent message when set reminder-time for a task

O

Oskar Vaia

Hi,

i have develop an Add-In which save tasks in a non primary task-folder.
I use the Outlook-Object-Modell (MAPI) to save the tasks.
Always when my application save a task with a remindertime, a message like
the follow appairs:

"The reminder for ... will not displayed. Are you agreed vor this?"

Is there a method to prevent this message?

bye

Oskar
 
S

Sue Mosher [MVP-Outlook]

You could save the task to the user's default Tasks folder, then move it to the non-primary folder.
 
O

Oskar Vaia

Hi Sue,

thx for the tip. I can resolve the problem with the move-method. ;-)
But one question:

My personalized Outlook-form starts by click a button (VB-Script) a
vb.net-application.

Here the VB-Script-code:
---
sub commandbutton6_click()
Dim CB5Caption
CB5Source = 1
Set MB = CreateObject("InkassiOutlookTools.WordFunction") ' this is
my vb.net-application
call MB.Mahnbrieferstellung()
msgbox "OK"
CB5Source = 0
Item.Close olSave
end sub
---

In this application then i use the move-method. This works fine.
After the vb.net-application have finished his work the vb-script-code of
the form should finished his work.
But nothing happens. Could it be, that the move-method in my
vb.net-application automatically closes my outlook-item?

bye

Oskar
 
S

Sue Mosher [MVP-Outlook]

I'm very confused now. What object represents the new task that your code creates? How is running code on a form related to creating that new task?
 
O

Oskar Vaia

Hi Sue,

i try to illustrate my problem for new:
(sorry, but my english is not so good; maybe it will helps to learn it
better if i frequently will write here in the newsgroup. :) )

Well: my personalized task-form, which is into a new task-folder (not the
primary task-folder) has a button therein, what i have create.
When i click the button, a VB.NET procedure starts.

Here is the VBScript-code behind the form, which respond to the
button-click-event.

---
sub commandbutton6_click()
Dim CB5Caption
CB5Source = 1
Set MB = CreateObject("InkassiOutlookTools.WordFunction") ' this is
my VB.NET-application
call MB.Mahnbrieferstellung() 'this is a procedure in the
VB.NET-application
msgbox "OK"
CB5Source = 0
Item.Close olSave
end sub
---

So far i think my illustration is ok, right?

Here is the code of the abovementioned VB.NET-procedure:

---
Dim myOlApp As New Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myitem As Outlook.TaskItem
Dim myitemP As Outlook.TaskItem
Dim ReminderDate As DateTime, newReminderTime As DateTime

myNamespace = myOlApp.GetNamespace("MAPI")
myitem = myNamespace.GetItemFromID(strEntryID, objStoreID)

ReminderDate = DateTime.UtcNow.AddDays(7)
newReminderTime = New System.DateTime(ReminderDate.Year,
ReminderDate.Month, ReminderDate.Day, 9, 0, 0)

myitem.UserProperties("MB1").Value = DateTime.UtcNow
myitem.UserProperties("Mahnung1").Value = True
myitem.UserProperties("aktMahnstufe").Value = "1"
myitem.Save()

Dim myPTaskFolder As Outlook.MAPIFolder =
myNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks)
myitem.Move(myPTaskFolder)

Dim myFolder As Outlook.MAPIFolder
Dim myFindItem As Outlook.TaskItem
myFolder =
myNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks)
myFindItem = myFolder.Items.Find("[GrID] =
'401780208129.11.20021728.02.20040-1128.69RD010173'")
myitemP = myNamespace.GetItemFromID(myFindItem.EntryID.ToString,
objStoreID)

myitemP.ReminderSet = True
myitemP.ReminderTime = newReminderTime
myitemP.Save()

Dim myPersTaskFolder As Outlook.MAPIFolder =
myNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks).Folders().Item("Inkassi")
'NEW
myitemP.Move(myPersTaskFolder)
myPersTaskFolder = Nothing
myPTaskFolder = Nothing
myNamespace = Nothing
myOlApp = Nothing
---

The variable "strEntryID" comprised the "EntryID" of the taskitem, which
launches my VB.NET-procedure by click on the abovementioned button.
The procedure changes some UserProperties.values on my opened taskitem, then
it save the opened taskitem.
Then the procedure moves the item to the primary task-folder. Then the
procedure searches for the moved item in the primary task-folder.
After that it sets the value for the properties "ReminderSet" and
"ReminderTime". It saves the task-item in the primary task-folder. Then the
procedure moves the modified task-item to the original position, back in the
other task-folder.

All this works fine and in this manner the user don't receive the message
"The reminder for ... will not displayed. Are you agreed for this?".

But here the cause, which don't fall me:
when the VB.NET-procedure has finished his work and gives the control back
to VBScript-code, so all the code after this code-line

call MB.Mahnbrieferstellung() 'this is a procedure in the
VB.NET-application

didn't executed.
When i debug my VBScript-code with the Microsoft Script Editor, so i can
see, that when the VB.NET-procedure gives back the control to the VBScript
code, this opens a few new "Script-elements", and it doesn't continue at the
Script-element, from which it starts by click the button on my personalized
task-form.
Why this? I think the reason must relate to the "move-method" in the
VB.NET-code. But i would use this manner to avoid the message "The reminder
for ... will not displayed. Are you agreed for this?"
Have you a tip, how it's possible to avoid the problem with the new open of
the few "Script-elements" and how the VBScript code can continue his right
way after he achieve back the control from the VB.NET-procedure?

thx & bye

Oskar
 
S

Sue Mosher [MVP-Outlook]

You shouldn't be moving an open item. If you're going to move it, close it first, then reopen it. If you're closing the item, setting CB5Source = 0 in code wouldn't seem to have any effect anyway, assuming CB5Source is a script variable.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


Oskar Vaia said:
Hi Sue,

i try to illustrate my problem for new:
(sorry, but my english is not so good; maybe it will helps to learn it
better if i frequently will write here in the newsgroup. :) )

Well: my personalized task-form, which is into a new task-folder (not the
primary task-folder) has a button therein, what i have create.
When i click the button, a VB.NET procedure starts.

Here is the VBScript-code behind the form, which respond to the
button-click-event.

---
sub commandbutton6_click()
Dim CB5Caption
CB5Source = 1
Set MB = CreateObject("InkassiOutlookTools.WordFunction") ' this is
my VB.NET-application
call MB.Mahnbrieferstellung() 'this is a procedure in the
VB.NET-application
msgbox "OK"
CB5Source = 0
Item.Close olSave
end sub
---

So far i think my illustration is ok, right?

Here is the code of the abovementioned VB.NET-procedure:

---
Dim myOlApp As New Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myitem As Outlook.TaskItem
Dim myitemP As Outlook.TaskItem
Dim ReminderDate As DateTime, newReminderTime As DateTime

myNamespace = myOlApp.GetNamespace("MAPI")
myitem = myNamespace.GetItemFromID(strEntryID, objStoreID)

ReminderDate = DateTime.UtcNow.AddDays(7)
newReminderTime = New System.DateTime(ReminderDate.Year,
ReminderDate.Month, ReminderDate.Day, 9, 0, 0)

myitem.UserProperties("MB1").Value = DateTime.UtcNow
myitem.UserProperties("Mahnung1").Value = True
myitem.UserProperties("aktMahnstufe").Value = "1"
myitem.Save()

Dim myPTaskFolder As Outlook.MAPIFolder =
myNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks)
myitem.Move(myPTaskFolder)

Dim myFolder As Outlook.MAPIFolder
Dim myFindItem As Outlook.TaskItem
myFolder =
myNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks)
myFindItem = myFolder.Items.Find("[GrID] =
'401780208129.11.20021728.02.20040-1128.69RD010173'")
myitemP = myNamespace.GetItemFromID(myFindItem.EntryID.ToString,
objStoreID)

myitemP.ReminderSet = True
myitemP.ReminderTime = newReminderTime
myitemP.Save()

Dim myPersTaskFolder As Outlook.MAPIFolder =
myNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks).Folders().Item("Inkassi")
'NEW
myitemP.Move(myPersTaskFolder)
myPersTaskFolder = Nothing
myPTaskFolder = Nothing
myNamespace = Nothing
myOlApp = Nothing
---

The variable "strEntryID" comprised the "EntryID" of the taskitem, which
launches my VB.NET-procedure by click on the abovementioned button.
The procedure changes some UserProperties.values on my opened taskitem, then
it save the opened taskitem.
Then the procedure moves the item to the primary task-folder. Then the
procedure searches for the moved item in the primary task-folder.
After that it sets the value for the properties "ReminderSet" and
"ReminderTime". It saves the task-item in the primary task-folder. Then the
procedure moves the modified task-item to the original position, back in the
other task-folder.

All this works fine and in this manner the user don't receive the message
"The reminder for ... will not displayed. Are you agreed for this?".

But here the cause, which don't fall me:
when the VB.NET-procedure has finished his work and gives the control back
to VBScript-code, so all the code after this code-line

call MB.Mahnbrieferstellung() 'this is a procedure in the
VB.NET-application

didn't executed.
When i debug my VBScript-code with the Microsoft Script Editor, so i can
see, that when the VB.NET-procedure gives back the control to the VBScript
code, this opens a few new "Script-elements", and it doesn't continue at the
Script-element, from which it starts by click the button on my personalized
task-form.
Why this? I think the reason must relate to the "move-method" in the
VB.NET-code. But i would use this manner to avoid the message "The reminder
for ... will not displayed. Are you agreed for this?"
Have you a tip, how it's possible to avoid the problem with the new open of
the few "Script-elements" and how the VBScript code can continue his right
way after he achieve back the control from the VB.NET-procedure?

thx & bye

Oskar
 
O

Oskar Vaia

Hi Sue,

i have do what you suggest me.
The problem isn't the content of the variable CB5Source; the problem is,
that the memoryload increases more than when i don't move the items from one
folder to another and back.
when i don't move the items by code, so the memoryload for the
outlook-process is about 300 KB; when i move the items like the code in my
previous posting, so the memoryload for the outlook-process is about 1500
KB. I don't understand why.

I only notice, that when i use the Microsoft Script Editor to debug the
forms-code, the opens Scriptelements doesn't all close.
Is this perhaps the reason for the upper memory usage?

thx & bye

Oskar
 
S

Sue Mosher [MVP-Outlook]

That sounds like a different issue. You may need to release objects more aggressively in your add-in(Marshal.ReleaseCOMObject, GC.College, GC.WaitForPendingFinalizers). Setting objects to Nothing in your script code is also good practice.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top