将项目移到Outlook中的文件夹时设置自定义值 [英] Set custom value when item moved to folder in outlook
问题描述
无论何时将电子邮件移至特定文件夹,我都希望在字段上设置日期. 该字段是自定义的,称为完成日期". 当项目移入文件夹(文件夹名称为"Completed")时,能否在VBA代码上获得一些帮助以设置自定义字段(日期).
I'm looking to set a Date on a field anytime an email is moved into a specific folder. the field is custom called "Completed Date". Could I get a little help on VBA code to set a custom field (date) when an item is moved into a folder (folder name is "Completed").
我最终希望报告接收到的项目(自定义表单电子邮件)到完成的时间(根据将电子邮件移至已完成的文件夹的操作.
I'm ultimately looking to report on the time an item (custom form email) was received to the time it was completed (as per the action of moving the email to a completed folder.
非常简单的售票系统,我非常了解:).
Very rudimentary ticketing system, I'm very aware :) .
谢谢
A
推荐答案
使用ItemAdd http: //www.outlookcode.com/article.aspx?id=62 ,在其中引用已完成"文件夹.
Use ItemAdd http://www.outlookcode.com/article.aspx?id=62 where you reference the "Completed" folder.
使用类似 http://www.vbaexpress.com/forum/showthread.php?5738-Need-to-Add-a-Userdefined-Property-to-Mail-Items
示例代码
对其进行更改,以使您不仅更新触发ItemAdd的一项即可更新文件夹中的所有项.
Change it so you do not update all items in the folder just the one item that triggered ItemAdd.
Option Explicit
Sub AddAUserDefinedProperty()
Dim olApplication As Outlook.Application
Dim olNameSpace As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Dim olItem As Object
Dim strDomain As String
Dim olProperty As Outlook.UserProperty
Set olApplication = New Outlook.Application
Set olNameSpace = olApplication.GetNamespace("Mapi")
Set olFolder = olNameSpace.GetDefaultFolder(olFolderJunk)
For Each olItem In olFolder.Items
strDomain = Mid(olItem.SenderEmailAddress, _
InStr(1, olItem.SenderEmailAddress, "@") + 1)
Set olProperty = olItem.UserProperties.Add("Domain", olText)
olProperty.Value = strDomain
Debug.Print olItem.SenderEmailAddress, olProperty.Value
olItem.Save
Next olItem
Set olApplication = Nothing
Set olNameSpace = Nothing
Set olFolder = Nothing
Set olProperty = Nothing
End Sub
此处还有更多参考资料 http://www .codeproject.com/Articles/427913/在Outlook中使用用户定义的字段
Even more reference material here http://www.codeproject.com/Articles/427913/Using-User-Defined-Fields-in-Outlook
这篇关于将项目移到Outlook中的文件夹时设置自定义值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!