Excel 2010 VBA Outlook电子邮件发件人后续标记

时间:2015-05-19 05:56:48

标签: excel vba email excel-vba outlook

我创建了以下代码,该代码会自动通过电子邮件发送工作簿,我希望在发送日期的2天内将发送的电子邮件标记为发件人跟进,以提醒我在2天内跟进发送的电子邮件。

我查看了其他论坛但没有成功,我找到的代码只为收件人设置了标志。

Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim SigString As String
Dim Signature As String
Dim wb As Workbook
Dim FileName As String
Dim wSht As Worksheet
Dim ShtName As String
Dim ws As Worksheet

ActiveWorkbook.SaveCopyAs ThisWorkbook.Path & "\" & "File Name " & Format(Now, "dd-mm-yy") & ".xlsm"

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.createitem(0)


strbody = " Please see the attached spreadsheet.

" & _"Please don't hesitate to contact me if you have any questions.
"


'Change only Mysig.htm to the name of your signature
SigString = Environ("appdata") & _
"\Microsoft\Signatures\Expediting Officer.htm"


If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If


On Error Resume Next


With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = ""
.HTMLBody = strbody & "
" & Signature
.display
.Attachments.Add ("File location"\"File Name " & Format(Now, "dd-mm-yy") & ".xlsm")
.display
.Importance = 2
End With

1 个答案:

答案 0 :(得分:0)

MailItem类提供以下属性来完成工作:

  • MarkAsTask - 将MailItem对象标记为任务,并为该对象指定任务间隔。
  • TaskDueDate - 设置一个Date值,表示此MailItem的任务的截止日期。
  • ReminderSet - 设置一个布尔值,如果为此项目设置了提醒,则该值为True。
  • ReminderTime - 设置一个日期,指明指定项目的提醒日期和时间。

参见示例代码:

 Public Sub FlagMessage(Item As Outlook.MailItem)
  With Item
    .MarkAsTask olMarkThisWeek
    ' sets a due date in 48 hours
    .TaskDueDate = Now + 2
    .ReminderSet = True
    .ReminderTime = Now + 2
    .Save
  End With
End Sub