Sending email with flag not working

时间:2017-04-24 08:51:43

标签: vba outlook outlook-vba outlook-2007

I have an Outlook 2007 macro that sends an email with flag for recipient but it doesn't work anymore.

I made a change to the code by mistake and now it doesn't work anymore.

The recipient doesn't see the email in TO DO and it doesn't show red on the email list.

Sub fff()
    Dim outApp As Object
    Dim OutMail As Object

    Dim datDue As Date
    datDue = DateAdd("d", 7, Date)


     Set OutMail = outApp.CreateItem(0)

    With OutMail
        .To = "me@yyy.com"
        .Subject = "test"
        .HtmlBody = "msg"

        .Importance = olImportanceHigh
        .FlagStatus = olFlagMarked
        .FlagRequest = "Follow up"
        .ReminderTime = datDue & " 17:00 PM"
        .ReminderOverrideDefault = True
        .ReminderSet = True
        .TaskStartDate = Date
        .TaskDueDate = datDue
        .Save
        .Send

    End With

End Sub

2 个答案:

答案 0 :(得分:2)

您的变量OutApp并不有用,在Outlook中直接使用时,Application应为Sub wittman() Dim OutMail As MailItem Dim datDue As Date datDue = DateAdd("d", 7, Date) Set OutMail = Application.CreateItem(0) With OutMail .To = "test@mail.com" .Subject = "test" .HTMLBody = "msg" .Importance = olImportanceHigh .FlagStatus = olFlagMarked .FlagRequest = "Follow up" .ReminderTime = datDue & " 17:00 PM" .ReminderOverrideDefault = True .ReminderSet = True .TaskStartDate = Date .TaskDueDate = datDue .Save .Send End With 'OutMail End Sub

我只测试该代码,它对我很有效(Outlook 2013):

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, forType type: PKPushType) {
    NSLog("pushRegistry:didReceiveIncomingPushWithPayload:forType:")

    if (type == PKPushType.voIP) {
        print(payload.dictionaryPayload)
        VoiceClient.sharedInstance().handleNotification(payload.dictionaryPayload, delegate: self)
    }
}

答案 1 :(得分:1)

您可以将任务发送给代理人:

Sub AssignTask() 
 Dim myItem As Outlook.TaskItem 
 Dim myDelegate As Outlook.Recipient 
 Set MyItem = Application.CreateItem(olTaskItem) 
 MyItem.Assign 
 Set myDelegate = MyItem.Recipients.Add("Eugene Astafiev") 
 myDelegate.Resolve 
 If myDelegate.Resolved Then 
   myItem.Subject = "Prepare Agenda for Meeting" 
   myItem.DueDate = Now + 30 
   myItem.Display 
   myItem.Send 
 End If 
End Sub

在运行此示例之前,请不要忘记使用有效的收件人名称替换“Eugene Astafiev”。

此外,您可以使用MailItem类的MarkAsTask方法将MailItem对象标记为任务,并为对象分配任务间隔。调用此方法会设置其他几个属性的值,具体取决于MarkInterval中提供的值。有关通过指定MarkInterval设置的属性的更多信息,请参阅OlMarkInterval Enumeration

您可能会发现How to set a flag to follow up using VBA文章有用。

相关问题