问题描述
我使用下面的代码将数据从新的帖子项目复制到另一个公共文件夹。
I am using the code below to copy data from a new post item into another public folder.
问题是,当有人打开并编辑现有项目时,代码再次触发,它会创建另一个项目。我希望代码只在首次创建项目时触发。
Problem is, when somebody opens and edits an existing item, the code fires again and it creates another item. I want the code to fire ONLY when the item is first created.
感谢任何帮助,谢谢。
Fergus。
功能Item_Write()
On Error Resume Next
设置olns = Item.Application.GetNamespace (" MAPI")
设置myFolder1 = olns.GetDefaultFolder(18)
设置myFolder2 = myFolder1.Folders(" Folder1")
设置myFolder3 = myFolder2.Folders(" Folder2")
设置myFolder4 = myFolder3.Folders(" Folder3")
设置myItem = myFolder4.Items.Add( " IPM.Post.StudentAbsence")
myItem.Subject = Item.Subject
myItem.Save
设置CC = Item.UserProperties(" Cc")
设置myApp = CreateObject(" Outlook.Application")
设置myItem = myApp.CreateItem(0)
with myItem
.To = CC
.Subject = Item.Subject
.Body = Item.Body
结束与
myItem.Send
结束函数
Function Item_Write()
On Error Resume Next
Set olns = Item.Application.GetNamespace("MAPI")
Set myFolder1 = olns.GetDefaultFolder(18)
Set myFolder2 = myFolder1.Folders("Folder1")
Set myFolder3 = myFolder2.Folders("Folder2")
Set myFolder4 = myFolder3.Folders("Folder3")
Set myItem = myFolder4.Items.Add("IPM.Post.StudentAbsence")
myItem.Subject = Item.Subject
myItem.Save
Set CC = Item.UserProperties("Cc")
Set myApp = CreateObject("Outlook.Application")
Set myItem = myApp.CreateItem(0)
With myItem
.To = CC
.Subject = Item.Subject
.Body = Item.Body
End With
myItem.Send
End Function
推荐答案
其次,您可以使用特殊属性(UserProperties)标记项目:检查您的自定义属性是否存在。如果是,则不执行任何操作,否则设置属性并运行创建新项目的代码。
Secondly, you can mark the item with a special property (UserProperties): check if your custom property exists. If yes, do nothing, otherwise set the property and run your code that created teh new item.
这篇关于使用Item_Write事件(Outlook窗体)防止重复输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!