Outlook 2010 - 从约会提醒创建电子邮件 - 多个类别

时间:2014-02-04 13:54:38

标签: vba email outlook

计划:Outlook 2010

要求:
在约会触发器触发时发送电子邮件。将使用超过1个类别。

问题:
日历显示VBA代码的第二部分中的正确类别,但是当电子邮件触发时,它将恢复为第一类并使用这些参数发送。代码如下:

Private Sub Application_Reminder(ByVal Item As Object)
Dim objMsg As MailItem
Set objMsg = Application.CreateItem(olMailItem)

If Item.MessageClass <> "IPM.Appointment" Then
    Exit Sub
End If

If Item.Categories <> "Cat - Test (1)" Then
    objMsg.To = Item.Location
    objMsg.Subject = Item.Subject & " | " & Format(Now, "YYYYMMDD")
    objMsg.HTMLBody = Format(Now, "Long Date") & Item.Body
    objMsg.CC = "email"
    objMsg.BCC = "email 1, 2, 3"
    objMsg.Categories = "Cat - Test (1)"
    objMsg.Send

    'this is the code that reverts to the one above at the time of sending, _
    'but looks as it should in the calendar preview.
    ElseIf Item.Categories <> "Cat - Test (2)" Then
    objMsg.To = Item.Location
    objMsg.Subject = Item.Subject & " | " & Format(Now, "YYYYMMDD")
    objMsg.HTMLBody = Format(Now, "Long Date") & Item.Body
    objMsg.CC = "email"
    objMsg.BCC = "emails"
    objMsg.Categories = "Cat - Test (2)"
    objMsg.Send
Else
    Exit Sub
End If

Set objMsg = Nothing
End Sub  

任何建议,似乎我可能会遗漏或许某种结束,或使用IF / elseIF的正确方法我尝试添加&amp;省略了一些IF,ElseIF,但我无法正确触发它。

我还创建了一个没有类别的日历约会,但是在“位置”字段中有一封电子邮件,它仍会触发宏运行。

Correct Cal view, Incorrect on Send
提前谢谢。

1 个答案:

答案 0 :(得分:1)

如果Item.Categories的值为"Cat - Test (2)",请查看您的代码,然后将objMsg.Categories设置为"Cat - Test (1)",尝试替换<>在if / elseif语句中使用=

相关问题