我设计了一个简单的解决方案,让五个人的团队自动了解团队的日常关键任务是否完成。我为每个任务创建一个单独的任务,并将任务的提醒设置为与任务的时间相同(前0分钟)。 结构是这样的; 任务所有者完成任务,拍摄屏幕截图(作为证明。这是必须的),并将其与预定义的文件名一起保存在特定的文件夹(file.jpg)中。 弹出相关的Outlook任务提醒,运行代码以查找此文件,如果找到该文件,则不执行任何操作;如果该文件不存在,请向团队发送一封电子邮件,说明任务尚未完成。 代码保存在Outlook的application_reminder下,而我在模块下也保存了一些功能。 在前一两个实例的任务提醒触发后,代码运行良好,但是由于某种原因而停止工作。提示弹出,但代码不运行。
- 知道为什么代码不起作用吗?有没有解决办法
- 关于这个问题?
- 您知道的任何其他解决方案,都在做我想做的事情。
- 我可以将其转换为vsto项目吗?这会更有效吗
- 解? (到目前为止,我在Visual Studio中什么也没做,但是我想
- 开始使用它)
我在下面粘贴了代码,仅供参考。正如我所说的,代码在最初的实例中起作用。但是总是欢迎提出改进建议。
Private Sub Application_Reminder(ByVal Item As Object)
Dim objPeriodicalMail As MailItem
If Item.Categories = "Screenshot" Then
Call Screenshot(Item.Subject)
End If
End Sub
*************************
Function reppdate() As Date 'returns previous working date
Dim yest As Date
Dim tatiller As Variant
tatiller = Array("19.05.2020", "06.05.2020", "05.05.2020", "04.05.2020", "01.05.2020", "01.01.2020") 'local holidays
j = -1
For i = 0 To UBound(tatiller)
yest = Format(DateAdd("w", j, Now()), "dd.mm.yyyy")
If yest = tatiller(i) Then
If Weekday(yest) = 2 Then
j = j - 3
Else: j = j - 1
End If
Else
If j < -1 Then
Exit For
Else: End If
End If
Next i
reppdate = yest
End Function
**************************************
Sub Screenshot(dosya As String)
yestt = reppdate()
Dim objMsg As MailItem
Set objMsg = Application.CreateItem(olMailItem)
vamsg = "Dikkat, " & dosya & ".jpg bulunamadi, rapor gönderilmemis mi!"
dosyaadi1 = "c:folder\" & Format(yestt, "yyyymm") & "\Daily\" & Format(yestt, "dd") & "\" & dosya & ".jpg"
baglanti = "<a href=" & dosyaadi1 & ">" & vamsg & "</a>"
If FileFolderExists(dosyaadi1) = False Then
msg = vamsg
Else
End If
objMsg.To = "vvvvv.com"
objMsg.Subject = msg
objMsg.Body = msg & " - " & dosyaadi1
objMsg.Send
Set objMsg = Nothing
End Sub
Categories
property value may include another string categories assigned. So, I'd suggest checking a substring with a particular value instead.Categories
is a delimited string of category names that have been assigned to an Outlook item. This property uses the character specified in the value name, sList, under HKEY_CURRENT_USER\Control Panel\International in the Windows registry, as the delimiter for multiple categories. To convert the string of category names to an array of category names, use the Microsoft Visual Basic functionSplit
.I'd suggest running the code under the debugger and see how it works and where it fails. Also, you may add an error-handling routine, see Error Handling in VBA.
There is no direct migration. Basically, you must create a new add-in project and add your event handler there. Then you can mode the code from VBA event handlers to the add-in's ones. See https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2007/aa830702(v=office.12)?redirectedfrom=MSDN and Create VSTO Add-ins for Office by using Visual Studio for more information.