Call Outlook procedure using VBScript

后端 未结 3 647

I have a procedure in Outlook that sends all the saved messages in Drafts folder.
Below is the code:

Public Sub SendMail()

Dim olApp As         


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-15 13:49

    Tried & Tested!

    Assuming that you have Outlook Application always running (according to comment below your question) you can do what you need in the following steps:

    1. add a new task in Outlook, set subject to: "run macro YourMacroName" and set time (plus cycles) when your macro should start.

    2. go to VBA Editor, open ThisOutlookSession module and add the following code inside (plus see the comments inside the code):

      Private Sub Application_Reminder(ByVal Item As Object)
      
      If TypeName(Item) = "TaskItem" Then
          Dim myItem As TaskItem
          Set myItem = Item
          If myItem.Subject = "run macro YourMacroName" Then
      
              Call YourMacroName    '...your macro name here
      
          End If
      End If
      End Sub
      

提交回复
热议问题