Outlook add-in 插件.Net开发经验-补充(2)

** ** 一些注意点:

具体需要做些什么,个人需要,我也不仔细说了,察看 msdn 就明白了。

我在开发过程中的一些注意,列一下:

1. 在单独类 _ oAddin _ 中处理,指定 progID

** 指定 ** ** progID **


  1<guidattribute("ca940fe1-1193-411b-82df-570a04491150"), progidattribute("addinforbible.oladdin")="">
  2
  3Public  Class  OutAddIn 
  4
  5End Class   
  6  
  72\.  清除  outlook的对象: 
  8
  9** 清除  outlook的对象:  **  
 10  
 11---  
 12  
 13_ Public  _ _ Sub  DisposeObject(  ByVal  obj  As  Object  )  _
 14
 15_ 'Wraps ReleaseCOMObject to provide a 'safe' disposal helper method.  _
 16
 17_ Dim  count  As  Integer  _
 18
 19_ Try  _
 20
 21_ If  obj  Is  Nothing  Then  _
 22
 23_ Exit  Try  _
 24
 25_ End  If  _
 26
 27_ If  Not  Marshal.IsComObject(obj)  Then  _
 28
 29_ Exit  Try  _
 30
 31_ End  If  _
 32
 33_ count = Marshal.ReleaseComObject(obj)  _
 34
 35_ While  count &gt; 0  _
 36
 37_ count = Marshal.ReleaseComObject(obj)  _
 38
 39_ End  While  _
 40
 41_ Catch  ex  As  SystemException  _
 42
 43_ Finally  _
 44
 45_ obj =  Nothing  _
 46
 47_ End  Try  _
 48
 49_ End  _ _ Sub  _  
 50  
 513\.  CDO1.21对象在Office的安装包里可以安装,使用例子: 
 52
 53** 设置  folder的default post message 属性为 自定义 form  **
 54
 55** 这个属性找了很久,  msdn里没有提及,留在这里吧,以后也不太会再作outlook开发了  **  
 56  
 57---  
 58  
 59_ g_olNamespace = m_olOutlookApp.Session  _
 60
 61_ g_olNamespace.Logon(, ,  False  ,  False  )  _
 62
 63_ g_objMAPISession =  New  MAPI.Session  _
 64
 65_ g_objMAPISession.Logon(, ,  False  ,  False  )  _
 66
 67_ Public  _ _ Function  SetFolderDftMsgPostClass(  ByVal  sFolderID  As  String  ,  ByVal  sStoreID  As  String  )  As  Boolean  _
 68
 69_ _
 70
 71_ Dim  objMAPIFolder  As  MAPI.Folder  _
 72
 73_ Dim  objMAPIFields  As  MAPI.Fields  _
 74
 75_ Const  PR_DEF_POST_DISPLAYNAME = &amp;H36E6001E  '定制form的显示名字  _
 76
 77_ Const  PR_DEF_POST_MSGCLASS = &amp;H36E5001E  '定制form的MessageClass名称  _
 78
 79_ Try  _
 80
 81_ objMAPIFolder = g_objMAPISession.GetFolder(sFolderID, sStoreID)  _
 82
 83_ objMAPIFields = objMAPIFolder.Fields  _
 84
 85_ Try  _
 86
 87_ If  objMAPIFields.Item(PR_DEF_POST_MSGCLASS).value = cVerseMessageClass  Then  _
 88
 89_ Exit  Try  _
 90
 91_ End  If  _
 92
 93_ Catch  ex  As  Exception  _
 94
 95_ With  objMAPIFields  _
 96
 97_ .Add(PR_DEF_POST_DISPLAYNAME, cVerseFormName)  _
 98
 99_ .Add(PR_DEF_POST_MSGCLASS, cVerseMessageClass)  _
100
101_ End  With  _
102
103_ objMAPIFolder.Update()  _
104
105_ End  Try  _
106
107_ Catch  ex  As  Exception  _
108
109_ Finally  _
110
111_ End  Try  _
112
113_ DisposeObject(objMAPIFields)  _
114
115_ DisposeObject(objMAPIFolder)  _
116
117_ End  _ _ Function  _  
118  
1194\.  初始化  outlook  对象,取得基本的对象。 
120
121** 初始化  ** ** outlook  ** ** 对象,取得基本的对象。  ** ** **  
122  
123---  
124  
125_ Imports  _ _ myOutlook = Microsoft.Office.Interop.Outlook  _
126
127_ _
128
129_ Public  _ _ g_olNamespace  As  myOutlook.NameSpace  '当前outlook session对象  _
130
131_ Public  _ _ g_oBaseFolder  As  myOutlook.MAPIFolder  '当前outlook folder对象  _
132
133_ Public  _ _ g_olApp  As  myOutlook.Application  '当前outlook对象  _
134
135_ _
136
137_ Public  _ _ g_sStoreID  As  String  _
138
139_ _
140
141_ Private  _ _ WithEvents  m_olExplorer  As  myOutlook.ExplorerClass  _
142
143_ '当前outlook explorer对象  _ _ _
144
145_ _
146
147_ g_olNamespace = m_olOutlookApp.Session  _
148
149_ g_olNamespace.Logon(, ,  False  ,  False  )  _
150
151_ m_olExplorer =  CType  (m_olOutlookApp.ActiveExplorer, myOutlook.ExplorerClass)  _
152
153_ g_oBaseFolder = g_olNamespace.Folders.Item(foldername)  _
154
155_ g_sStoreID = g_oBaseFolder.StoreID  _
156
157_ _
158
159_ _  
160  
161** 取得  ** ** folder  ** ** 对象:  ** _ _  
162  
163namespace.folders.Item(“foldername”)  _ _
164
165| 
166
167取得第一个名为  foldername  的  folder   
168  
169namespace  .GetFolderFromID(sFolderID,sStoreID)  ** **
170
171| 
172
173取得指定  ID  的  folder   
174  
175FolderID , StoreID 
176
177| 
178
179Folder.EntryID   
180  
181_ _</guidattribute("ca940fe1-1193-411b-82df-570a04491150"),>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus