Jump to content

I would like to automate the calendar publishing in Outlook 2010


peder303
 Share

Recommended Posts

Hi everyone,

 

I have a server (2012R2) with Outlook 2010 installed (Dutch, I know...) which uploads an .ics file to a WebDAV server.

Almost every day the publishing of the .ics file stops and I manually have to click "Publish online" select "Publish to a WebDAV server" (screenshot 1: webdav.jpg)

and click "OK" in the pop-up window that opens. (screenshot 2: webdav2.jpg)

Then the publishing continues again...

 

I want to automate these simple clicks. I have added 2 screenshots with the buttons i have to press.

The hard part is probably that Outlook is already running under a specific account and eveything has to be done under that specific user account.

(Please note: the screenshots are taken from my own account...)

Can anyone please assist me in creating the automation for this? I want to run this automation with the windows task scheduler so i can upload the file some times per hour.

 

Any help would be highly appreciated! Best regards, Peter Bos

 

webdav.jpg

webdav2.JPG

Link to comment
Share on other sites

you do realize you have Visual Basic for Applications built into Office apps? with outlook open and having focus, press the Alt and F11 keys and up pops the biggest built in automation tool you could want. you can probably find the script to do something similar to what you want to do.

 

otherwise, you had better study up on this, or use Visual Studio and C# or something of that nature.

 

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

googled it. found this vba macro you can use right inside outlook using that Alt-F11 trick I told you about. this worked with Exchange 2007 so it should work. you may need to edit to suit

https://arstechnica.com/civis/viewtopic.php?t=130508

" The following VBA macro will look for new appointments in the resource calendar and copy them to a personal folder calendar. I have the personal folder continuing to publish to the WebDAV server. 

To use it, paste the following code into ThisOutlookSession in the VBA editor. Replace SOURCEMAILBOX with the user name of the resource folder, and DESTINATION with the name of the personal folder calendar. Save it and close it. Under the main Outlook window, go to Tools->Macros->Security. Change the setting to either Warnings for all Macros or No security check, unless you sign it yourself. Restart Outlook and it should work every time a new appointment is added. "

Public WithEvents myOlItems As Outlook.Items



Private Sub Application_Startup()

    Set fld = GetCalendar("SOURCEMAILBOX")

    If Not fld Is Nothing Then

        Set myOlItems = fld.Items

    End If

End Sub



Private Sub myOlItems_ItemAdd(ByVal Item As Object)

    Dim copyAppt As Outlook.AppointmentItem

    Dim movedAppt As Outlook.AppointmentItem

    

    ' Add new appointment to second calendar

    Set copyAppt = Item.Copy

    

    Set fld = GetFolder("Personal Folders\DESTINATION")

    If Not fld Is Nothing Then

        Set movedAppt = copyAppt.Move(fld)

    End If



End Sub



Public Function GetCalendar(strPath As String) As MAPIFolder

    Dim myNamespace As Outlook.NameSpace

    Dim myRecipient As Outlook.Recipient

    Dim CalendarFolder As Outlook.Folder

    

    Set myNamespace = Application.GetNamespace("MAPI")

    Set myRecipient = myNamespace.CreateRecipient(strPath)

    myRecipient.Resolve

    If myRecipient.Resolved Then

        Set GetCalendar = myNamespace.GetSharedDefaultFolder(myRecipient, olFolderCalendar)

    End If

End Function



Public Function GetFolder(strFolderPath As String) As MAPIFolder

  ' folder path needs to be something like

  ' "Public Folders\All Public Folders\Company\Sales"

  Dim objApp As Outlook.Application

  Dim objNS As Outlook.NameSpace

  Dim colFolders As Outlook.Folders

  Dim objFolder As Outlook.MAPIFolder

  Dim arrFolders() As String

  Dim I As Long

  On Error Resume Next



  strFolderPath = Replace(strFolderPath, "/", "\")

  arrFolders() = Split(strFolderPath, "\")

  Set objApp = CreateObject("Outlook.Application")

  Set objNS = objApp.GetNamespace("MAPI")

  Set objFolder = objNS.Folders.Item(arrFolders(0))

  If Not objFolder Is Nothing Then

    For I = 1 To UBound(arrFolders)

      Set colFolders = objFolder.Folders

      Set objFolder = Nothing

      Set objFolder = colFolders.Item(arrFolders(I))

      If objFolder Is Nothing Then

        Exit For

      End If

    Next

  End If



  Set GetFolder = objFolder

  Set colFolders = Nothing

  Set objNS = Nothing

  Set objApp = Nothing

End Function

 

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

Hi Earthshine,

First of all, thanks for your replies. IThe first post is interesting, the second post is not what i want to achieve.

I just want to automate the publishing of the built-in calendar. I only need to automate a few mouseclicks or keyboard shortcuts.

(Keyboard shortcuts would be awesome also)

But again, i am gratefull that you took the time for me. Thanks!

Does anyone else have an idea how to automate a few clicks in Outlook?

Link to comment
Share on other sites

OK, so I did a little test... LOL. I have Office 365. this clicks the Publish Online button and then sends the Ctrl-U key commands to Publish it via the little dropdown menu.

this code should work for you. I am using US language is all the difference here. I used the AutoIt info tool to get the class of the ribbon, yours might be different than what I have due to version differences. Mine was "[CLASS:NetUIHWND; INSTANCE 4]", yours may differ. Check the ribbon with the AutoIt Info Tool

 

#include ".\OutlookEX 1.3.1.0\OutlookEx.au3"

WinActivate("Calendar - Earthshine@AutoIt.com - Outlook")

ControlClick("Calendar - Earthshine@AutoIt.com - Outlook", "", "[CLASS:NetUIHWND; INSTANCE:4]");
Send("{LCTRL}-U")

 

So you need to first click on that whole ribbon menu in outlook, then you can send Ctrl key plus the hotkey letter in the menu items to get to each feature, in this case the menu was P&ublish Online where the U is the hotkey. this should get you started. 

here is the download to the UDF, though you may not need the UDF if all you need is to do what I posted in the code. But if you need to do complex things, you will need it. my simple example doesn't even need the include.

 

you will just need to add an AutoIt ControlClick to click that OK button that shows up for you. use the AutoIt Info Tool on that button and add the command to the small example at the end. problem should be solved. I can't see a button as we don't have a WebDav so MS browser comes up for me with options, else I would have had that button click in the sample code.

cheers, happy automation.

 

 

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

Thanks Earthshine,

 

I tried your code, adjusted the email address en the instance number.

But there is no action at all... I still do not see in the code what is supposed to be happening...

In this screenshot you see a shortcut which can be clicked with the Alt + 3

After that a screen pops up and i just want to press enter. (We have Outlook 2010 btw)

webdav3.JPG

Edited by peder303
Link to comment
Share on other sites

Yes, I am trying that:

#include ".\OutlookEX\OutlookEx.au3"

WinActivate("Calendar - emailaddress - Outlook")

ControlClick("Calendar - emailaddress - Outlook", "", "[CLASS:NetUIHWND; INSTANCE:4]");
Send("{ALT}{3}")
Send("{DOWN}")
Send("{ENTER}")
Sleep (500)
Send("{ENTER}")

 

That should do the trick, but it just opens a recurring appointment...???

Edited by peder303
Link to comment
Share on other sites

I have added a Send ("ALT")

Which clicks that ALT button and reveals the "shortcuts" I can see that that happens...

 

ControlClick("Calendar - email@address - Outlook", "", "[CLASS:NetUIHWND; INSTANCE:4]");
Send("{ALT}")
Send("{ALT}{3}")  <-- This is the command for holding alt and pressing "3" simultaneously?
Send("{ALT}{u}") <-- This is the command for holding alt and pressing "u" simultaneously?
#Send("{ENTER}")
Sleep (500)
Send("{ENTER}")

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...