David Kim
Posts: 4
Joined: 2009-02-12
|
I am trying to open a custom outlook form I have created and want to check the user defined fields in this form on a close event. I know the commands in VB script but need to know the same commands in ADX Add-In Express.
1) To Open a New Custom Form.
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.Application.GetNamespace("MAPI")
Set myfolder = myNameSpace.Folders("Public Folders").Folders("All Public Folders").Folders("Bugs").Folders("Bug Tracking")
Set myItem = myFolder.Items.Add("IPM.Task.BugTracking")
myItem.Display
2) To Access a User Defined Field
Function Item_Close()
If Item.Subject = "" Then
Item.UserProperties("tmpIsNew").Value = True
Else
Item.UserProperties("tmpIsNew").Value = False
End If
End Function
|
|
Andrei Smolin
Add-in Express team
Posts: 18794
Joined: 2006-05-11
|
Hello David,
1) To Open a New Custom Form.
Add-in Express add-ins targeting Outlook provide the OutlookApp property which returns an Outlook.Application. Below is a raw sketch:
dim myNameSpace as Outlook.Namespace = OutlookApp.Session
Dim myfolder as Outlook.MAPIFolder = myNameSpace.Folders.Item("Public Folders").Folders.Items("...")
dim item as Object = myFolder.Items.Add("IPM.Task.BugTracking")
dim taskItem as Outlook.TaskItem = CType(item, Outlook.TaskItem)
taskItem.Display
2) To Access a User Defined Field
Replace UserProperties("...") with UserProperties.Item("...").
Now please read my post http://www.add-in-express.com/creating-addins-blog/2008/10/30/releasing-office-objects-net/; releasing COM objects is a must in Outlook add-ins. Say in 1) you must release myNameSpace, myfolder, taskItem (or item) as well as all COM objects that you get via Folders and Folders.Item(...). The same applies to UserProperties and UserProperties.Item("...").
Andrei Smolin
Add-in Express Team Leader |
|