A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Refer original Item from new form



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 25th 07, 06:42 PM posted to microsoft.public.outlook.program_forms
sriramna
external usenet poster
 
Posts: 12
Default Refer original Item from new form

I have a new email form created by a custom action in a public folder-
based form derived from IPM.Task. I need to record the plain-text
contents of the new email for reference back in the originating Task
form, just before it is sent.

It is easy enough to get a handle on the new mail form in the script
of the original Task form, but how do I do it the other way (locate
the Task item which spawned this item, from script in the email)?

The problem is that the CurrentFolder could be anything, since the
user is opening the Task Item through a hyperlink in a mail in his
Inbox. Therefore even to search the items in a folder, I will have to
find a way of locating the public folder containing the Task, in the
email script. Short of hard-coding the path, what are the options?

--
Sriram

Ads
  #2  
Old March 25th 07, 09:00 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Refer original Item from new form

You would need some kind of identifier. THe easiest solution might be be to have the CustomAction event handler on the task set the value of the new message's BillingInformation property to the EntryID of the original task. That way, the message form's code can get the ID from its own BillingInformation property and then use Namespace.GetItemFromID to return the message.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"sriramna" wrote in message ups.com...
I have a new email form created by a custom action in a public folder-
based form derived from IPM.Task. I need to record the plain-text
contents of the new email for reference back in the originating Task
form, just before it is sent.

It is easy enough to get a handle on the new mail form in the script
of the original Task form, but how do I do it the other way (locate
the Task item which spawned this item, from script in the email)?

The problem is that the CurrentFolder could be anything, since the
user is opening the Task Item through a hyperlink in a mail in his
Inbox. Therefore even to search the items in a folder, I will have to
find a way of locating the public folder containing the Task, in the
email script. Short of hard-coding the path, what are the options?

--
Sriram

  #3  
Old March 26th 07, 09:17 AM posted to microsoft.public.outlook.program_forms
sriramna
external usenet poster
 
Posts: 12
Default Refer original Item from new form

Thanks for the tip. I presume the GetItemFromID method will need the
StoreID parameter also, since the folder could be anywhere in the
public folder tree.

So I've gotten upto here in the custom action code:

Function Item_CustomAction(ByVal myAction, ByVal myResponse)
Select Case myAction.Name
Case "Correspondence"
myResponse.BillingInformation = EntryID
myRepsonse.Mileage = Parent.StoreID
myResponse.display
Case Else
'Do nothing
End Select
End Function

This errors out with "Object Required: Parent.StoreID". Anything
wrong with the code?

The Correspondence item is based on IPM.Note and addressed like a
Reply. The originating form has been duly saved to the folder before
triggering the custom action.

--
Sriram


On Mar 26, 1:00 am, "Sue Mosher [MVP-Outlook]"
wrote:
You would need some kind of identifier. THe easiest solution might be be to have the CustomAction event handler on the task set the value of the new message's BillingInformation property to the EntryID of the original task. That way, the message form's code can get the ID from its own BillingInformation property and then use Namespace.GetItemFromID to return the message.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx



"sriramna" wrote in oglegroups.com...
I have a new email form created by a custom action in a public folder-
based form derived from IPM.Task. I need to record the plain-text
contents of the new email for reference back in the originating Task
form, just before it is sent.


It is easy enough to get a handle on the new mail form in the script
of the original Task form, but how do I do it the other way (locate
the Task item which spawned this item, from script in the email)?


The problem is that the CurrentFolder could be anything, since the
user is opening the Task Item through a hyperlink in a mail in his
Inbox. Therefore even to search the items in a folder, I will have to
find a way of locating the public folder containing the Task, in the
email script. Short of hard-coding the path, what are the options?


  #4  
Old March 26th 07, 12:25 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Refer original Item from new form

Item.Parent, not Parent.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"sriramna" wrote in message oups.com...
Thanks for the tip. I presume the GetItemFromID method will need the
StoreID parameter also, since the folder could be anywhere in the
public folder tree.

So I've gotten upto here in the custom action code:

Function Item_CustomAction(ByVal myAction, ByVal myResponse)
Select Case myAction.Name
Case "Correspondence"
myResponse.BillingInformation = EntryID
myRepsonse.Mileage = Parent.StoreID
myResponse.display
Case Else
'Do nothing
End Select
End Function

This errors out with "Object Required: Parent.StoreID". Anything
wrong with the code?

The Correspondence item is based on IPM.Note and addressed like a
Reply. The originating form has been duly saved to the folder before
triggering the custom action.

--
Sriram


On Mar 26, 1:00 am, "Sue Mosher [MVP-Outlook]"
wrote:
You would need some kind of identifier. THe easiest solution might be be to have the CustomAction event handler on the task set the value of the new message's BillingInformation property to the EntryID of the original task. That way, the message form's code can get the ID from its own BillingInformation property and then use Namespace.GetItemFromID to return the message.



"sriramna" wrote in oglegroups.com...
I have a new email form created by a custom action in a public folder-
based form derived from IPM.Task. I need to record the plain-text
contents of the new email for reference back in the originating Task
form, just before it is sent.


It is easy enough to get a handle on the new mail form in the script
of the original Task form, but how do I do it the other way (locate
the Task item which spawned this item, from script in the email)?


The problem is that the CurrentFolder could be anything, since the
user is opening the Task Item through a hyperlink in a mail in his
Inbox. Therefore even to search the items in a folder, I will have to
find a way of locating the public folder containing the Task, in the
email script. Short of hard-coding the path, what are the options?


  #5  
Old March 26th 07, 12:56 PM posted to microsoft.public.outlook.program_forms
sriramna
external usenet poster
 
Posts: 12
Default Refer original Item from new form

Duh... except for wrestling with a typo, I've got it working. But
I've run up against an unexepected problem - the writeback to the
original (Task) form field does not "take" presumably because it is
already open in another Inspector:

In the original form:
===
Function Item_CustomAction(ByVal myAction, ByVal myResponse)
Select Case myAction.Name
Case "Correspondence"
myResponse.Mileage = EntryID
myResponse.BillingInformation = Parent.StoreID
myResponse.To = Userproperties.find("FromID").Value
myResponse.display
Case Else
End Select

and in the Correspondence form:

Sub Item_Send()
dim strHistory
set myItem =
Application.GetNamespace("MAPI").GetItemFromID(Mil eage,BillingInformation)
' store message and write it into the log
strHistory = myItem.userproperties.find("History").Value
If (item.body "") then
myItem.Userproperties("History") = item.Body & chr(13) & chr(10) &
strHistory
myItem.Save
End If
End Sub

Problem here = the user field History is _not_ updated! Any pointers
why? Closing the original Task form before hitting Send also does not
appear to help.

--
Sriram

On Mar 26, 1:00 am, "Sue Mosher [MVP-Outlook]"
wrote:
You would need some kind of identifier. THe easiest solution might be be to have the CustomAction event handler on the task set the value of the new message's BillingInformation property to the EntryID of the original task. That way, the message form's code can get the ID from its own BillingInformation property and then use Namespace.GetItemFromID to return the message.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx



"sriramna" wrote in oglegroups.com...
I have a new email form created by a custom action in a public folder-
based form derived from IPM.Task. I need to record the plain-text
contents of the new email for reference back in the originating Task
form, just before it is sent.


It is easy enough to get a handle on the new mail form in the script
of the original Task form, but how do I do it the other way (locate
the Task item which spawned this item, from script in the email)?


The problem is that the CurrentFolder could be anything, since the
user is opening the Task Item through a hyperlink in a mail in his
Inbox. Therefore even to search the items in a folder, I will have to
find a way of locating the public folder containing the Task, in the
email script. Short of hard-coding the path, what are the options?


  #6  
Old March 26th 07, 01:30 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Refer original Item from new form

Are you sure the code is running in the message form? Did you publish it with the Send Form Definition with Item box unchecked?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"sriramna" wrote in message oups.com...
Duh... except for wrestling with a typo, I've got it working. But
I've run up against an unexepected problem - the writeback to the
original (Task) form field does not "take" presumably because it is
already open in another Inspector:

In the original form:
===
Function Item_CustomAction(ByVal myAction, ByVal myResponse)
Select Case myAction.Name
Case "Correspondence"
myResponse.Mileage = EntryID
myResponse.BillingInformation = Parent.StoreID
myResponse.To = Userproperties.find("FromID").Value
myResponse.display
Case Else
End Select

and in the Correspondence form:

Sub Item_Send()
dim strHistory
set myItem =
Application.GetNamespace("MAPI").GetItemFromID(Mil eage,BillingInformation)
' store message and write it into the log
strHistory = myItem.userproperties.find("History").Value
If (item.body "") then
myItem.Userproperties("History") = item.Body & chr(13) & chr(10) &
strHistory
myItem.Save
End If
End Sub

Problem here = the user field History is _not_ updated! Any pointers
why? Closing the original Task form before hitting Send also does not
appear to help.

--
Sriram

On Mar 26, 1:00 am, "Sue Mosher [MVP-Outlook]"
wrote:
You would need some kind of identifier. THe easiest solution might be be to have the CustomAction event handler on the task set the value of the new message's BillingInformation property to the EntryID of the original task. That way, the message form's code can get the ID from its own BillingInformation property and then use Namespace.GetItemFromID to return the message.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx



"sriramna" wrote in oglegroups.com...
I have a new email form created by a custom action in a public folder-
based form derived from IPM.Task. I need to record the plain-text
contents of the new email for reference back in the originating Task
form, just before it is sent.


It is easy enough to get a handle on the new mail form in the script
of the original Task form, but how do I do it the other way (locate
the Task item which spawned this item, from script in the email)?


The problem is that the CurrentFolder could be anything, since the
user is opening the Task Item through a hyperlink in a mail in his
Inbox. Therefore even to search the items in a folder, I will have to
find a way of locating the public folder containing the Task, in the
email script. Short of hard-coding the path, what are the options?


  #7  
Old March 26th 07, 02:07 PM posted to microsoft.public.outlook.program_forms
sriramna
external usenet poster
 
Posts: 12
Default Refer original Item from new form

Sure, code is running in the Message form - various MsgBox statements
confirm that.

The only quirk is that the value of the History property does not
change even with the Save statement. The existing text is retained.

Yes, the "Send Form Definition" is checked, so code will not execute
in the recipient's Inbox, but that is not an issue. The code does get
processed while sending.

--
Sriram

On Mar 26, 5:30 pm, "Sue Mosher [MVP-Outlook]"
wrote:
Are you sure the code is running in the message form? Did you publish it with the Send Form Definition with Item box unchecked?

"sriramna" wrote in ooglegroups.com...
Duh... except for wrestling with a typo, I've got it working. But
I've run up against an unexepected problem - the writeback to the
original (Task) form field does not "take" presumably because it is
already open in another Inspector:


In the original form:
===
Function Item_CustomAction(ByVal myAction, ByVal myResponse)
Select Case myAction.Name
Case "Correspondence"
myResponse.Mileage = EntryID
myResponse.BillingInformation = Parent.StoreID
myResponse.To = Userproperties.find("FromID").Value
myResponse.display
Case Else
End Select


and in the Correspondence form:


Sub Item_Send()
dim strHistory
set myItem =
Application.GetNamespace("MAPI").GetItemFromID(Mil eage,BillingInformation)
' store message and write it into the log
strHistory = myItem.userproperties.find("History").Value
If (item.body "") then
myItem.Userproperties("History") = item.Body & chr(13) & chr(10) &
strHistory
myItem.Save
End If
End Sub


Problem here = the user field History is _not_ updated! Any pointers
why? Closing the original Task form before hitting Send also does not
appear to help.


--
Sriram


On Mar 26, 1:00 am, "Sue Mosher [MVP-Outlook]"
wrote:
You would need some kind of identifier. THe easiest solution might be be to have the CustomAction event handler on the task set the value of the new message's BillingInformation property to the EntryID of the original task. That way, the message form's code can get the ID from its own BillingInformation property and then use Namespace.GetItemFromID to return the message.


--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"sriramna" wrote in oglegroups.com...
I have a new email form created by a custom action in a public folder-
based form derived from IPM.Task. I need to record the plain-text
contents of the new email for reference back in the originating Task
form, just before it is sent.


It is easy enough to get a handle on the new mail form in the script
of the original Task form, but how do I do it the other way (locate
the Task item which spawned this item, from script in the email)?


The problem is that the CurrentFolder could be anything, since the
user is opening the Task Item through a hyperlink in a mail in his
Inbox. Therefore even to search the items in a folder, I will have to
find a way of locating the public folder containing the Task, in the
email script. Short of hard-coding the path, what are the options?- Hide quoted text -


  #8  
Old March 26th 07, 02:56 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Refer original Item from new form

Checking "Send form definition with item" ensures that code won't run on any items, new or received. I can't imagine why a MsgBox would fire under that condition.

In this statement:

set myItem = _
Application.GetNamespace("MAPI").GetItemFromID(Mil eage,BillingInformation)

you should use the correct Item.prop_name syntax to get the property values:

Set myItem = _
Application.Session.GetItemFromID( _
Item.Mileage, Item.BillingInformation)

and then check whether the item exists, something like:

If Not myItem Is Nothing Then
If Item.Body "" Then
strNewHistory = item.Body & chr(13) & chr(10)
myItem.Userproperties("History") = _
strNewHistory & myItem.Userproperties("History")
MsgBox myItem.Userproperties("History")
myItem.Save
myItem.Close
Set myItem = Nothing
End If
End If
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"sriramna" wrote in message ups.com...
Sure, code is running in the Message form - various MsgBox statements
confirm that.

The only quirk is that the value of the History property does not
change even with the Save statement. The existing text is retained.

Yes, the "Send Form Definition" is checked, so code will not execute
in the recipient's Inbox, but that is not an issue. The code does get
processed while sending.

--
Sriram

On Mar 26, 5:30 pm, "Sue Mosher [MVP-Outlook]"
wrote:
Are you sure the code is running in the message form? Did you publish it with the Send Form Definition with Item box unchecked?

"sriramna" wrote in ooglegroups.com...
Duh... except for wrestling with a typo, I've got it working. But
I've run up against an unexepected problem - the writeback to the
original (Task) form field does not "take" presumably because it is
already open in another Inspector:


In the original form:
===
Function Item_CustomAction(ByVal myAction, ByVal myResponse)
Select Case myAction.Name
Case "Correspondence"
myResponse.Mileage = EntryID
myResponse.BillingInformation = Parent.StoreID
myResponse.To = Userproperties.find("FromID").Value
myResponse.display
Case Else
End Select


and in the Correspondence form:


Sub Item_Send()
dim strHistory
set myItem =
Application.GetNamespace("MAPI").GetItemFromID(Mil eage,BillingInformation)
' store message and write it into the log
strHistory = myItem.userproperties.find("History").Value
If (item.body "") then
myItem.Userproperties("History") = item.Body & chr(13) & chr(10) &
strHistory
myItem.Save
End If
End Sub


Problem here = the user field History is _not_ updated! Any pointers
why? Closing the original Task form before hitting Send also does not
appear to help.


--
Sriram


On Mar 26, 1:00 am, "Sue Mosher [MVP-Outlook]"
wrote:
You would need some kind of identifier. THe easiest solution might be be to have the CustomAction event handler on the task set the value of the new message's BillingInformation property to the EntryID of the original task. That way, the message form's code can get the ID from its own BillingInformation property and then use Namespace.GetItemFromID to return the message.


"sriramna" wrote in oglegroups.com...
I have a new email form created by a custom action in a public folder-
based form derived from IPM.Task. I need to record the plain-text
contents of the new email for reference back in the originating Task
form, just before it is sent.


It is easy enough to get a handle on the new mail form in the script
of the original Task form, but how do I do it the other way (locate
the Task item which spawned this item, from script in the email)?


The problem is that the CurrentFolder could be anything, since the
user is opening the Task Item through a hyperlink in a mail in his
Inbox. Therefore even to search the items in a folder, I will have to
find a way of locating the public folder containing the Task, in the
email script. Short of hard-coding the path, what are the options?- Hide quoted text -


  #9  
Old March 26th 07, 03:42 PM posted to microsoft.public.outlook.program_forms
sriramna
external usenet poster
 
Posts: 12
Default Refer original Item from new form

OK, I've made the changes suggested. I also realised that the
Item_Write event of the original form also fires upon a Save, which
was apparently the cause of the problem. I've got it fixed and
everything working shipshape. This completes my requirement.

A couple of points:
1. I thought the Item object is implicit in references to properties
in script, which was the reason I was leaving it out.
2. The message form is published to a public folder. I presume that
when the item is created, code is executed since the Item is not yet
saved outside the public folders. You are right that once the
Correspondence message reaches the user's Inbox, code is not
executed. I would expect this since forms published in a public
folder are trusted, while the one-off form in the user's Inbox (as a
result of sending with form definition) is not. Or perhaps the admin
has set up the Outlook Security settings appropriately...

Thanks for your quick responses which got this project completed in
short order.

--
Sriram

On Mar 26, 6:56 pm, "Sue Mosher [MVP-Outlook]"
wrote:
Checking "Send form definition with item" ensures that code won't run on any items, new or received. I can't imagine why a MsgBox would fire under that condition.

In this statement:

set myItem = _
Application.GetNamespace("MAPI").GetItemFromID(Mil eage,BillingInformation)

you should use the correct Item.prop_name syntax to get the property values:

Set myItem = _
Application.Session.GetItemFromID( _
Item.Mileage, Item.BillingInformation)

and then check whether the item exists, something like:

If Not myItem Is Nothing Then
If Item.Body "" Then
strNewHistory = item.Body & chr(13) & chr(10)
myItem.Userproperties("History") = _
strNewHistory & myItem.Userproperties("History")
MsgBox myItem.Userproperties("History")
myItem.Save
myItem.Close
Set myItem = Nothing
End If
End If
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"sriramna" wrote in oglegroups.com...
Sure, code is running in the Message form - various MsgBox statements
confirm that.


The only quirk is that the value of the History property does not
change even with the Save statement. The existing text is retained.


Yes, the "Send Form Definition" is checked, so code will not execute
in the recipient's Inbox, but that is not an issue. The code does get
processed while sending.


--
Sriram


On Mar 26, 5:30 pm, "Sue Mosher [MVP-Outlook]"
wrote:
Are you sure the code is running in the message form? Did you publish it with the Send Form Definition with Item box unchecked?


"sriramna" wrote in ooglegroups.com...
Duh... except for wrestling with a typo, I've got it working. But
I've run up against an unexepected problem - the writeback to the
original (Task) form field does not "take" presumably because it is
already open in another Inspector:


In the original form:
===
Function Item_CustomAction(ByVal myAction, ByVal myResponse)
Select Case myAction.Name
Case "Correspondence"
myResponse.Mileage = EntryID
myResponse.BillingInformation = Parent.StoreID
myResponse.To = Userproperties.find("FromID").Value
myResponse.display
Case Else
End Select


and in the Correspondence form:


Sub Item_Send()
dim strHistory
set myItem =
Application.GetNamespace("MAPI").GetItemFromID(Mil eage,BillingInformation)
' store message and write it into the log
strHistory = myItem.userproperties.find("History").Value
If (item.body "") then
myItem.Userproperties("History") = item.Body & chr(13) & chr(10) &
strHistory
myItem.Save
End If
End Sub


Problem here = the user field History is _not_ updated! Any pointers
why? Closing the original Task form before hitting Send also does not
appear to help.


--
Sriram


On Mar 26, 1:00 am, "Sue Mosher [MVP-Outlook]"
wrote:
You would need some kind of identifier. THe easiest solution might be be to have the CustomAction event handler on the task set the value of the new message's BillingInformation property to the EntryID of the original task. That way, the message form's code can get the ID from its own BillingInformation property and then use Namespace.GetItemFromID to return the message.


"sriramna" wrote in oglegroups.com...
I have a new email form created by a custom action in a public folder-
based form derived from IPM.Task. I need to record the plain-text
contents of the new email for reference back in the originating Task
form, just before it is sent.


It is easy enough to get a handle on the new mail form in the script
of the original Task form, but how do I do it the other way (locate
the Task item which spawned this item, from script in the email)?


The problem is that the CurrentFolder could be anything, since the
user is opening the Task Item through a hyperlink in a mail in his
Inbox. Therefore even to search the items in a folder, I will have to
find a way of locating the public folder containing the Task, in the
email script. Short of hard-coding the path, what are the options?


  #10  
Old March 26th 07, 03:56 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Refer original Item from new form

1) Good coding practice means using implicit parent objects, especially when you're asking someone else to decipher your code.

2) No, you should never check "Send form definition with item" if you want code to run. There is no concept of "trusting" forms specifically in public folders.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"sriramna" wrote in message oups.com...
OK, I've made the changes suggested. I also realised that the
Item_Write event of the original form also fires upon a Save, which
was apparently the cause of the problem. I've got it fixed and
everything working shipshape. This completes my requirement.

A couple of points:
1. I thought the Item object is implicit in references to properties
in script, which was the reason I was leaving it out.
2. The message form is published to a public folder. I presume that
when the item is created, code is executed since the Item is not yet
saved outside the public folders. You are right that once the
Correspondence message reaches the user's Inbox, code is not
executed. I would expect this since forms published in a public
folder are trusted, while the one-off form in the user's Inbox (as a
result of sending with form definition) is not. Or perhaps the admin
has set up the Outlook Security settings appropriately...

Thanks for your quick responses which got this project completed in
short order.

--
Sriram

On Mar 26, 6:56 pm, "Sue Mosher [MVP-Outlook]"
wrote:
Checking "Send form definition with item" ensures that code won't run on any items, new or received. I can't imagine why a MsgBox would fire under that condition.

In this statement:

set myItem = _
Application.GetNamespace("MAPI").GetItemFromID(Mil eage,BillingInformation)

you should use the correct Item.prop_name syntax to get the property values:

Set myItem = _
Application.Session.GetItemFromID( _
Item.Mileage, Item.BillingInformation)

and then check whether the item exists, something like:

If Not myItem Is Nothing Then
If Item.Body "" Then
strNewHistory = item.Body & chr(13) & chr(10)
myItem.Userproperties("History") = _
strNewHistory & myItem.Userproperties("History")
MsgBox myItem.Userproperties("History")
myItem.Save
myItem.Close
Set myItem = Nothing
End If
End If

"sriramna" wrote in oglegroups.com...
Sure, code is running in the Message form - various MsgBox statements
confirm that.


The only quirk is that the value of the History property does not
change even with the Save statement. The existing text is retained.


Yes, the "Send Form Definition" is checked, so code will not execute
in the recipient's Inbox, but that is not an issue. The code does get
processed while sending.


--
Sriram


On Mar 26, 5:30 pm, "Sue Mosher [MVP-Outlook]"
wrote:
Are you sure the code is running in the message form? Did you publish it with the Send Form Definition with Item box unchecked?


"sriramna" wrote in ooglegroups.com...
Duh... except for wrestling with a typo, I've got it working. But
I've run up against an unexepected problem - the writeback to the
original (Task) form field does not "take" presumably because it is
already open in another Inspector:


In the original form:
===
Function Item_CustomAction(ByVal myAction, ByVal myResponse)
Select Case myAction.Name
Case "Correspondence"
myResponse.Mileage = EntryID
myResponse.BillingInformation = Parent.StoreID
myResponse.To = Userproperties.find("FromID").Value
myResponse.display
Case Else
End Select


and in the Correspondence form:


Sub Item_Send()
dim strHistory
set myItem =
Application.GetNamespace("MAPI").GetItemFromID(Mil eage,BillingInformation)
' store message and write it into the log
strHistory = myItem.userproperties.find("History").Value
If (item.body "") then
myItem.Userproperties("History") = item.Body & chr(13) & chr(10) &
strHistory
myItem.Save
End If
End Sub


Problem here = the user field History is _not_ updated! Any pointers
why? Closing the original Task form before hitting Send also does not
appear to help.


--
Sriram


On Mar 26, 1:00 am, "Sue Mosher [MVP-Outlook]"
wrote:
You would need some kind of identifier. THe easiest solution might be be to have the CustomAction event handler on the task set the value of the new message's BillingInformation property to the EntryID of the original task. That way, the message form's code can get the ID from its own BillingInformation property and then use Namespace.GetItemFromID to return the message.


"sriramna" wrote in oglegroups.com...
I have a new email form created by a custom action in a public folder-
based form derived from IPM.Task. I need to record the plain-text
contents of the new email for reference back in the originating Task
form, just before it is sent.


It is easy enough to get a handle on the new mail form in the script
of the original Task form, but how do I do it the other way (locate
the Task item which spawned this item, from script in the email)?


The problem is that the CurrentFolder could be anything, since the
user is opening the Task Item through a hyperlink in a mail in his
Inbox. Therefore even to search the items in a folder, I will have to
find a way of locating the public folder containing the Task, in the
email script. Short of hard-coding the path, what are the options?


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why is Insert/Item greyed out on custom form? John Lane Outlook - Using Forms 2 March 23rd 07 05:49 PM
Could not save item. the form required to view this message cannot matt hullinger Outlook - Calandaring 1 February 20th 07 10:48 PM
forward a mail item with form region Nikolas Outlook - Using Forms 7 December 1st 06 06:34 PM
Moving data from Form Item to olMailItem djohnson Outlook - Using Forms 5 August 10th 06 05:41 AM
How can I disable an item on a form Josianne Outlook - Using Forms 2 March 31st 06 04:46 PM


All times are GMT +1. The time now is 06:32 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.