peder303

I would like to automate the calendar publishing in Outlook 2010

22 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Earthshine
A beacon in the night
I can raise my eyes to 
Earthshine -- RUSH, Earthshine - Vapor Trails

Share this post


Link to post
Share on other sites

you may even need this

 


Earthshine
A beacon in the night
I can raise my eyes to 
Earthshine -- RUSH, Earthshine - Vapor Trails

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Earthshine
A beacon in the night
I can raise my eyes to 
Earthshine -- RUSH, Earthshine - Vapor Trails

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Sorry, deleted because already posted the OutlookEx UDF 

Edited by Earthshine

Earthshine
A beacon in the night
I can raise my eyes to 
Earthshine -- RUSH, Earthshine - Vapor Trails

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Earthshine
A beacon in the night
I can raise my eyes to 
Earthshine -- RUSH, Earthshine - Vapor Trails

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Look at the Send command help to send alt 3


Earthshine
A beacon in the night
I can raise my eyes to 
Earthshine -- RUSH, Earthshine - Vapor Trails

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#11 ·  Posted

Did you use the autoit info tool do to get the correct class and instance for your ribbon?  It may be completely different  then what office 365 users


Earthshine
A beacon in the night
I can raise my eyes to 
Earthshine -- RUSH, Earthshine - Vapor Trails

Share this post


Link to post
Share on other sites

#12 ·  Posted

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}")

Share this post


Link to post
Share on other sites

#13 ·  Posted

Send (“{Alt}3”)


Earthshine
A beacon in the night
I can raise my eyes to 
Earthshine -- RUSH, Earthshine - Vapor Trails

Share this post


Link to post
Share on other sites

#14 ·  Posted

Instance: 2

Share this post


Link to post
Share on other sites

#15 ·  Posted

Just now, peder303 said:

Instance: 2

MêHhhh... I just see the ALT button being pressed...

Nothing else happens

Share this post


Link to post
Share on other sites

#16 ·  Posted

Sorry add a dash

Send(“{Alt}-3”)


Earthshine
A beacon in the night
I can raise my eyes to 
Earthshine -- RUSH, Earthshine - Vapor Trails

Share this post


Link to post
Share on other sites

#17 ·  Posted

You now have enough information to complete your quest if you have more questions read the documentation it explains how to use the send command


Earthshine
A beacon in the night
I can raise my eyes to 
Earthshine -- RUSH, Earthshine - Vapor Trails

Share this post


Link to post
Share on other sites

#18 ·  Posted

Thanks @Earthshine!!! Many thanks!

1 person likes this

Share this post


Link to post
Share on other sites

#19 ·  Posted

... still doesn't work, but... i'll get there!

Share this post


Link to post
Share on other sites

#20 ·  Posted

glad to be of help.


Earthshine
A beacon in the night
I can raise my eyes to 
Earthshine -- RUSH, Earthshine - Vapor Trails

Share this post


Link to post
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